feat: Expose toDataURL and toBlob Canvas APIs via onUpdate prop#406
Open
ObaidBuilds wants to merge 1 commit into
Open
feat: Expose toDataURL and toBlob Canvas APIs via onUpdate prop#406ObaidBuilds wants to merge 1 commit into
ObaidBuilds wants to merge 1 commit into
Conversation
Owner
|
I'm not against the premise here but I am curious about what makes this mechanism better than something more simple. The underlying canvas node is available directly via the ref. Now, that doesn't give you the same BUT I don't use this component to its fullest so I'm up for understanding better. Edit: see also #388 where this has come up previously |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adds an optional
onUpdatecallback prop to the<QRCodeCanvas>component to expose standard canvastoDataURLandtoBlobexport methods. This enables consumers to easily download or process the generated QR code image without complicating the component's main API parameters. To prevent parent component rendering loops, the exposed API object reference remains stable across renders.Changes
onUpdatecallback toQRCodeCanvasand exported its typescript type definitionQRCodeCanvasUpdateAPIs.useMemoreference to prevent parent component re-render loops.useEffecthook.How to use
You can pass the
onUpdatecallback to<QRCodeCanvas>and use the received APIs to download the QR code image: