Skip to content

Add page and onLoadSuccess props to PDFPreviewer - #59

Closed
ishpaul777 wants to merge 1 commit into
Expensify:mainfrom
ishpaul777:ishpaul-102435-pdf-page-prop
Closed

ishpaul777 wants to merge 1 commit into
Expensify:mainfrom
ishpaul777:ishpaul-102435-pdf-page-prop

Conversation

@ishpaul777

@ishpaul777 ishpaul777 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Details

Adds two optional props to PDFPreviewer, so App can flip through pages of a multi-page PDF receipt.

  • page: the 1-indexed page to show. The previewer scrolls to it whenever it changes, including after the document finishes loading, so a page requested early isn't lost.
  • onLoadSuccess: fires once every page has been measured, i.e. when the pages can actually be shown. It's called through a ref, because measuring a large PDF can take seconds and the caller may have re-rendered with a new callback in the meantime.

Both props are optional. When they're left out, behaviour is unchanged, so existing callers aren't affected.

Related Issues

Expensify/App#102435

Manual Tests

No automated tests in this repo. Tested through the App PR below: copied this build into App's node_modules, opened a 106-page PDF receipt, and confirmed the pill appears once the PDF loads and that previous/next scroll to the right page. Also checked that the full-screen PDF viewer, which passes neither prop, behaves as before.

Linked PRs

Expensify/App#102776

Lets consumers show a specific page and know when the document is ready,
so callers can flip pages without exposing the internal list ref.
@ishpaul777

Copy link
Copy Markdown
Contributor Author

Not needed anymore: the App PR renders the visible page directly with react-pdf, so it no longer depends on these props. See Expensify/App#102776

@ishpaul777 ishpaul777 closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant