04-Apr-2023
.
Admin
Hi Guys,
In this blog, I will lean you how to use qrcode in react native. You can easily use qrcode in react native. First i will create import namespace qrcodea from react-native-qrcode, after I will using qrcode using for react-native-qrcode in react native example.
Here, I will give you full example for simply display qrcode using react native as bellow.
Step 1 - Create project
In the first step Run the following command for create project.
expo init Nicesnippets
Step 2 - Installation of Dependency
In the step, Run the following command for installation of dependency.
To use qrcode you need to npm install react-native-qrcode --save.
To install this open the terminal and jump into your project
cd Nicesnippets
Run the following command
yarn add react-native-qrcode-svg
In this step, You will open App.js file and put the code.
import React from 'react';
import { StyleSheet, Button, View, SafeAreaView, Text, Alert } from 'react-native';
import QRCode from 'react-native-qrcode-svg';
const App = () => (
<SafeAreaView style={styles.container}>
<View>
<QRCode
value="https://www.nicesnippets.com/"
style={styles.qrcodeBox}
logoSize={300}
/>
</View>
</SafeAreaView>
);
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems:'center',
backgroundColor:'#e2e2e2'
}
});
export default App;
Step 4 - Run project
In the last step run your project using bellow command.
npm start
Output
It will help you...
#React Native