React-pdf: Failed prop type: Invalid prop `loading` supplied to `Document`, expected a ReactNode.

Created on 28 May 2020  路  5Comments  路  Source: wojtekmaj/react-pdf

When I use a custom loader I receive this error:

Failed prop type: Invalid prop loading supplied to Document, expected a ReactNode.

this is my code:

  const renderLoader = () => (
    <div className={isDesktop() ? 'container-centered-desktop' : 'container-centered-mobile'} >
      <div className="loader"></div>
    </div>
  );
<Document
            loading={renderLoader}
...
          >

Anyone Can help me?

  • Chrome 81
  • React-PDF 4.1.0
  • React version 16.8.6
  • Webpack 4.29.6
bug

Most helpful comment

Holy crap, 3 years of development and no one ever noticed it :D Fixing right away. Will be available in next v5 beta or stable release.

All 5 comments

I am currently having the same error on my console when I add a custom render function for the loader!

Any ideas on what could be causing this issue?

Holy crap, 3 years of development and no one ever noticed it :D Fixing right away. Will be available in next v5 beta or stable release.

Lol! Literally just tried loading for the first time in years of having it in our project and looked this up. What a crazy thing.

Per the docs can we expect it to take Strings and Functions alike (assuming they will return jsx markup)?

Yes, any valid node or a function returning one will do.

Note: This fix was cherry-picked to v4.2.0 release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Crackiii picture Crackiii  路  3Comments

shivekkhurana picture shivekkhurana  路  4Comments

nnnikolay picture nnnikolay  路  4Comments

douglasrcjames picture douglasrcjames  路  4Comments

wangzhidavid picture wangzhidavid  路  4Comments