react-native-qrimage-decoder
QR image decoder libraries require linking...
So this library does not require linking.
But now still require Expo on Android.
I will response as soon as possible not require Expo on Android.
Instration
npm install react-native-qrimage-decoder --save
Usage
;;; ; const styles = StyleSheet; Component { superprops; thisstate = src: null ; } onPressPath = async { try const image = await ImagePicker; this; catch err console; } onPressBase64 = async { try const image = await ImagePicker; if imageuri > 0 let mimetype; const ext = imageuri; if ext === '.jpg' || ext === '.jpeg' || ext === '.jpe' mimetype = 'image/jpeg'; else if ext === '.png' mimetype = 'image/png'; else if ext === '.gif' mimetype = 'image/gif'; if mimetype this; catch err console; } { Alert; } { Alert; } { return <View style=stylescontainer> <TouchableOpacity style=stylesbutton onPress=thisonPressPath> <Text style=stylesbuttonText>画像を選択'\n'return image </Text> </TouchableOpacity> <TouchableOpacity style=stylesbutton onPress=thisonPressBase64> <Text style=stylesbuttonText>画像を選択'\n'return image base64</Text> </TouchableOpacity> <QRdecoder src=thisstatesrc onSuccess=thisonSuccess onError=thisonError /> </View> ; }
Checkout example.
QRdecoder API
Name | Type | Default | Description |
---|---|---|---|
src | string | null | Image path(file:///xxxxxx or https://xxxxx or http://xxxxx) or data:${mimetype};base64,${image.base64} |
onSuccess | func | (data) => {} | Called when qr decode success. |
onError | func | (data) => {} | Called when qr decode error. |
onError, return data(string) is below.
- QR code not found :
error decoding QR Code
- Image load failed :
Failed to load the image
Note : dataURL suppoert is iOS only.