zpao / qrcode.react

A <QRCode/> component for use with React.

Home Page:https://zpao.github.io/qrcode.react/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I show the loading status before the QR code comes out?

qingfengmy opened this issue · comments

I have two modes, they show different QR codes, when switching, the QR code can not be switched immediately, before the new QR code comes out, I need to show the loading.

This is generally a problem with React components. My advice would be to use the mode as a key when rendering, eg return <QRCodeCanvas key={mode} ... />. This will force React to throw away the old instance rather than attempt to reuse it. This would be most useful for QRCodeCanvas, which will reuse the actual <canvas> DOM node and does that outside of the render cycle.