diegomura / diegomura/react-pdf
Firefox: Broken route navigation & blank page when browsers 'back' button clicked
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 1.3k
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
In my React App (version 18.2), I'm navigating to a new route `/document` which reads the document content from the `location.state` property, and in turn, renders the PDF document using the `PDFViewer` component.
Upon the initial render, the document appears as expected.
However, when I click on the back button in the browser to return to the previous page:
- The user is NOT navigated back to the previous route (route unchanged)
- The `/document` page (in which the PDF renders) is now blank.
*Microsoft Edge behaves as expected*
**To Reproduce**
Steps to reproduce the behavior in Firefox:
1. Create a component which returns the `PDFViewer` component and some arbitrary document content, and add a specific route for it in your `react-router-dom` Route configuration.
2. From a different route and component, use the `useNavigate` hook to navigate to the component created in Step 1
3. Notice the document opens and displays as expected
4. Click 'Back' in the browser and you should get a blank screen
**Expected behavior**
The user should be navigated back to the previous route.
**Desktop:**
- OS: MacOS Sonoma 14.5
- Browser: Firefox 127.0.2 (64-bit)
- React-pdf version: v3.4.4
Contributor guide
Assessment
This issue has not been assessed yet.