I am new in React-Native and I am stuck at one place to do in React-Native.
This is my one component :-
const ConentQR = (
content: string,
logo: Image.propTypes.source,
logoSize: number,
) => {
return (
<QRCode
color={Colors.DARK_PURPLE}
content={content}
codeStyle={'dot'}
outerEyeStyle={'diamond'}
logo={logo}
logoSize={logoSize}
backgroundColor={'transparent'}
/>
);
};
The problem is I am facing in react native,This component (<QRCode) take some time to generate QR, so how I can put this block in any background thread so that I can show loader to user until it get prepared. I am getting stuck at this place and unable to resolve that for while.
Please help anyone
You could use the
InteractionManagerto schedule tasks in the backgroundI am using
useStateto keep track on the qr code andInteractionManager.runAfterInteractionsto schedule the generation in the background. If the qr code is not ready it displays a loader. The generation happens in thegenerateQRCode()function.