-
Notifications
You must be signed in to change notification settings - Fork 217
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
how to auto size #181
Comments
I have the same exact use case here. Specifically these situations
|
I don't understand what you're saying. What I mean is that I want the size of the QR code to automatically increase as the content increases, but the size of the QR code generated by this component is fixed |
@sweetyguazi I had the same issue. I ended up not using this package and used the For instance: import {useEffect, useState} from 'react';
import {SvgXml} from 'react-native-svg';
import QRCode from 'qrcode';
export default ({data}) => {
const [svgXml, setSvgXml] = useState();
useEffect(() => {
QRCode.toString(data, {type: 'svg' /* other options */ })
.then(setSvgXml)
.catch(error => {
console.error('Unable to render SVG Code', error);
// Do something with the error
});
}, [data]);
return svgXml ? <SvgXml xml={svgXml} width="100%" height="100%" /> : null /* ActivityIndicator? */;
} The only downside is that you'll have to handle the logo yourself. I didn't need the logo yet, so I haven't tried implementing this myself. However, if I had to take a stab at implementing it, this is what I would do: I would nest the QRCode SVG inside a root SVG with a predefined view box and nest the logo inside the root, centering the logo to the root SVG and not the QRCode SVG. Hope this helps. |
@jefawks3 , this gave it an extra padding....🤷🏽♀️ |
I want the QR code size to automatically change with parameters such as content, error correction level, and code width, rather than fixed size. What should I do?
The text was updated successfully, but these errors were encountered: