bitjson / qr-code

A no-framework, no-dependencies, customizable, animate-able, SVG-based <qr-code> HTML element.
https://qr.bitjson.com/
MIT License
1.17k stars 58 forks source link

Programmatic rendering #3

Open chrislondon opened 1 year ago

chrislondon commented 1 year ago

I'm using React and the library doesn't seem to recognize elements generated on the fly. Is there a programmatic way to generate a QR code?

lanchana commented 1 year ago

+1

predam commented 1 year ago

Hello guys, I am using this web component in React like this.

import * as qr from "@bitjson/qr-code";

const YourComponent = () => {
     useEffect(() => {qr.defineCustomElements(window)}, [])
     return (
         <>
          <qr-code
              contents="https://bitjson.com"
              style={{ width: "200px", height: "200px" }}></qr-code>
         <>)'
}

I hope it helps!