react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

Error when returning an array on render prop

Open davbrito opened this issue 2 years ago • 1 comments

Describe the bug

When I try something like:

<View
  render={({ pageNumber }) => (
    items.map(item => <Text>{item.label}, page: {pageNumber}</Text>)
  )}
/>

React Pdf throws an exception

To Reproduce Steps to reproduce the behavior including code snippet (if applies):

  1. Create a document with react PDF
  2. Pass the render prop and return an array from there
  3. It throwa

Codesanbox showing the errro: https://codesandbox.io/s/objective-greider-i5p544

Expected behavior It should work normally as if the array was passed as children.

Screenshots image

Desktop (please complete the following information):

  • OS: Windows and Linux
  • Browser Chrome
  • React-pdf version v2.1.2

davbrito avatar Jun 06 '22 16:06 davbrito

I also can't return a fragment or anything other than a react-pdf primitive.

davbrito avatar Jun 07 '22 16:06 davbrito

I was also running into this problem and came up with a potential fix in #2056

jasnross avatar Oct 15 '22 00:10 jasnross