We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug When you use the function updateInstance from usePDF in a useEffect to update and re-rendered the PDF, i doesn't seem to work
Code
const [update, setUpdate] = useState(false) const [instance, updateInstance] = usePDF({ document: <Document title="doc1"> <Page > <View > <Text>document 1</Text> </View> </Page> </Document> }); useEffect(() => { if (update) { console.log('update to doc2') updateInstance({ document: <Document title="doc2"> <Page > <View > <Text>document 2</Text> </View> </Page> </Document> }) } setUpdate(true) }, [update]) return instance.url && <object data={instance.url} type="application/pdf" height="100%" width="100%"></object>`
Expected behavior I would have expected the PDF to re-render and show Document 2
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered:
Hi, i tried like this and it works, i just replaced the setUpdate in your useEffect with false.
`` const [update, setUpdate] = useState(false)
const [instance, updateInstance] = usePDF({ document: <EstimateTemplatePdf currentEstimate={currentEstimate}/> }); useEffect(() => { if (update) { updateInstance({ document: <EstimateTemplatePdf currentEstimate={currentEstimate}/> }) } setUpdate(false) }, [update])
Sorry, something went wrong.
@pierrecazeneuve and @DesignmonkeyJim
Does updateInstance accept an argument?
updateInstance
According to the definition of usePDF (here: https://github.com/diegomura/react-pdf/blob/master/packages/renderer/src/dom/usePDF.js#L66-L71), the updateInstance function does not accept any arguments (by that, I mean that, when arguments are passed to the function, the function ignores them). The TypeScript type information for the usePDF hook (here: https://github.com/diegomura/react-pdf/blob/master/packages/renderer/index.d.ts#L472-L474) confirms that to me.
usePDF
Successfully merging a pull request may close this issue.
Describe the bug
When you use the function updateInstance from usePDF in a useEffect to update and re-rendered the PDF, i doesn't seem to work
Code
Expected behavior
I would have expected the PDF to re-render and show Document 2
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: