Add RenderContext in onRenderSuccess #1957
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! Thanks for this amazing library!
This PR is just proposing a small addon regarding a issue i faced when building my own pdf viewer on top of react-pdf.
In my case, i need to know the specs that
<Page/>
element renders with, so i can tell whether the rendered version is the version i want.Context: i faced the flickering issue when toggling specs like rotate, width, height.
To fix this, I added sth on top by leveraging on css transform that applied on the 'prev page', to shape it look like the page that about being rendered. (Getting inspirations from here #418)
However, when i keep toggling the specs of the page, i realized that the
onRenderSuccess
for the outdated specs might still be called.ie: i quickly toggle it like: {rotate:90, width:100} -> {rotate: 180, width: 200} -> {rotate: 270, width: 200}
the renderSuccess callback for {rotate: 180, width: 200} might be triggered, even though the specs are already changed to {rotate: 270, width: 200}.
Thus, adding the
renderContext
param in the params will help me to know whether the onRenderSuccess is for rendering the correct specs.