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

TypeError: Cannot read properties of undefined (reading 'return')

Open Sogeman opened this issue 2 years ago • 3 comments

Describe the bug Updating to Version 4.x results in Error TypeError: Cannot read properties of undefined (reading 'return') as soon as updateInstance runs in a useEffect. It worked perfectly on 3.4.5 I don't see anything in the 4.0.0 release that should cause this.

called like this useEffect( () => { updateInstance(); }, // eslint-disable-next-line react-hooks/exhaustive-deps [ locale, title, widthLabel, selectedVariant, specifications, selectedUpgrade, ], );

Expected behavior The Template is updated with the new data

Desktop (please complete the following information):

  • OS: MacOS, Windows
  • Browser: all
  • React-pdf version 9.1.1 with react-pdf/renderer at anything over 3.4.5

Sogeman avatar Nov 21 '24 13:11 Sogeman

I'm facing the exact same issue. Love to know if there's a solution for it.

mathewcst avatar Nov 21 '24 14:11 mathewcst

In v4 updateInstace requires a document as param.

E.g.:

updateInstance(
			<ReportPDF
				theme={selectedTheme}
				data={data}
				generatedOn={generatedOn}
				reportStartTime={reportStartTime}
				reportEndTime={reportEndTime}
				period={period}
			/>,
		)

My problem is that changing the theme throws the same return error.

mathewcst avatar Nov 21 '24 14:11 mathewcst

I think this is a duplicate of https://github.com/diegomura/react-pdf/issues/2957

63r6o avatar Nov 21 '24 17:11 63r6o