sanity-io / block-content-to-react

Deprecated in favor of @portabletext/react
https://github.com/portabletext/react-portabletext
MIT License
161 stars 25 forks source link

Failed `blocks` prop type #13

Closed mikaelbalin closed 5 years ago

mikaelbalin commented 5 years ago

Versions

@sanity/block-content-to-react    2.0.6
react                             16.8.0-alpha.1

Issue

I've a pretty standard setup:

import BlockContent from "@sanity/block-content-to-react";

const Footer = ({ footerCards }) => (
  {footerCards.map(footerCard => (
    <div key={footerCard._id}>
      <FooterCard title={footerCard.title}>
        <BlockContent blocks={footerCard.information} />
      </FooterCard>
    </div>
  ))}
);

export default Footer;

But I receive a warning in the console:

Warning: Failed prop type: The prop `blocks` is marked as required in `SanityBlockContent`, but its value is `undefined`.

But everything else except this error seems to work fine and value of footerCard.information isn't undefined.

mikaelbalin commented 5 years ago

Sorry, found the problem, my bad.

wispyco commented 4 years ago

Im having the same issue, could you shed some light on what error you had.

mikaelbalin commented 4 years ago

@wispyco Sadly I don't remember what happened, so I can't reproduce this error.

wispyco commented 4 years ago

I figured it out, I was using the wrong name of the field in my query so blocks was undefined. Thanks for responding tho.

Lilkedus commented 2 years ago

I figured it out, I was using the wrong name of the field in my query so blocks was undefined. Thanks for responding tho.

Could you please elaborate more on this? Not sure if you still remember though.