Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Allow passing a React ref down to canvas element #115

Open
tcchau opened this issue Aug 7, 2020 · 2 comments
Open

Feature request: Allow passing a React ref down to canvas element #115

tcchau opened this issue Aug 7, 2020 · 2 comments

Comments

@tcchau
Copy link

tcchau commented Aug 7, 2020

It would be nice if the library could do this, so that we can avoid querySelector() and the like and use idiomatic React, i.e. useRef()/createRef() instead.

@RnzTejada
Copy link

Any suggestion?, i have the same problem

@yaser-alazm
Copy link

You cannot use ref on the original QRCode component, as a work around it you can wrap the QRCode component with a div element and pass the rep into the div element like so:

              <div ref={qrCodeEl}>
                <QRCode
                  value='qr-value'
                  size={175}
                />
              </div>

and then you can get the QRCode canvas element like so:
const canvas = qrCodeEl.current.children[0]

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

No branches or pull requests

3 participants