ReactFix
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • React
  • React Native
  • Programming
  • Object Oriented Programming

Thursday, December 15, 2022

[FIXED] How to scan a qr code in React Native cli?

 December 15, 2022     command-line-interface, javascript, qr-code, react-native, typescript   

Issue

Is there anyone who has a tutorial or code how to read a qr code in React Native cli that actually works in the current React Native version? I tried so many tutorials and docs and nothing works. It would be nice if it works in tsx.


Solution

Use the react-native-qrcode-scanner package in React Native to scan QR codes. Here is an illustration of how you may employ it:

import QRCodeScanner from 'react-native-qrcode-scanner';

const MyQRCodeScanner = () => {
  const onSuccess = (e) => {
    console.log(e.data);
    // e.data contains the QR code data
  };

  return (
    <QRCodeScanner onRead={onSuccess} />
  );
};


Answered By - Catalin Stefan
Answer Checked By - - Pedro (ReactFix Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Post Older Post Home

Featured Post

Is Learning React Difficult?

React is difficult to learn, no ifs and buts. React isn't inherently difficult to learn. It's a framework that's different from ...

Total Pageviews

Copyright © ReactFix