You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using tato30/vue-pdf in a Vue 3 project to display PDFs dynamically when clicking on a table row. The PDF URL updates correctly, but the viewer only displays the first clicked document. When selecting another document, the viewer does not update to show the new PDF, even though the URL is correct (verified via console logs).
It seems like usePDF() might not be reacting properly to URL changes.
Steps to Reproduce:
Render a table with multiple documents, each with a unique PDF URL.
When a user clicks a table row, the pdfUrl is updated (correct URL is logged).
The PdfViewer component is supposed to update with the new PDF, but it only shows the first document.
Example code snippet (simplified)
I think your issue is that you aren't passing in a Ref to the usePDF function. The multiple PDF example has a single const pdfSource = ref('') can be used to update the url that the usePDF function uses to render.
I think your code won't need the mounted function piece and will look something like this:
const pdfSource = ref(props.pdfUrl || '')
const { pdf, pages } = usePDF(pdfSource);
// Watch for changes in the `pdfUrl` prop and update the PDF accordingly
watch(() => props.pdfUrl, (newUrl) => {
pdfSource.value = newPdf;
});
I am using tato30/vue-pdf in a Vue 3 project to display PDFs dynamically when clicking on a table row. The PDF URL updates correctly, but the viewer only displays the first clicked document. When selecting another document, the viewer does not update to show the new PDF, even though the URL is correct (verified via console logs).
It seems like usePDF() might not be reacting properly to URL changes.
Steps to Reproduce:
Render a table with multiple documents, each with a unique PDF URL.
When a user clicks a table row, the pdfUrl is updated (correct URL is logged).
The PdfViewer component is supposed to update with the new PDF, but it only shows the first document.
Example code snippet (simplified)
The text was updated successfully, but these errors were encountered: