Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: Failed prop type: Invalid prop fixed supplied to Image #9

Open
NikkiJonesR opened this issue Aug 28, 2019 · 3 comments
Open

Comments

@NikkiJonesR
Copy link

NikkiJonesR commented Aug 28, 2019

Hi there,

I'm experiencing issues with the fixed property not being recognized. However, the component is rendering just fine.

Console error:
Warning: Failed prop type: Invalid prop fixedsupplied toImage. in Image (at fixed_image.js:14)

Component:

import React from 'react'
import SbEditable from 'storyblok-react'
import Img from 'gatsby-image'
import { getFixedGatsbyImage } from 'gatsby-storyblok-image'

const FixedImage = ({ blok }) => {
  if (blok.image !== 'undefined' && blok.image !== '') {
    const fixedProps = getFixedGatsbyImage(blok.image, {
      width: 900
    });

    return (
      <SbEditable content={blok}>
        <Img fixed={fixedProps} />
      </SbEditable>
    )
  }
  return (
    <SbEditable content={blok}>
      <p>Please upload image</p>
    </SbEditable>
  )
}

export default FixedImage
@modulareverything
Copy link

@NikkiJonesR Did you ever find a fix for this?

@Qurus
Copy link

Qurus commented Mar 4, 2021

Any news on this issue? I have also this warning
Warning: Failed prop type: The prop fluid or fixed is marked as required in Image, but their values are both undefined.

@modulareverything
Copy link

modulareverything commented Mar 4, 2021

@Qurus There's a really annoying flaw in Storyblok in that it doesn't return null values to otherwise empty fields, it returns undefined. The best way to handle this is to use something like PropTypes to handle the undefined value, and return it as null, that way you can conditionally return the Img tag if the field isn't empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants