Reputation: 21
I'm currently trying to build an App with React Native in which the user can enter data, generate a QR-Code and then also share that same QR-Code.
Entering the Data and generating the QR-Code is working as intended. However the sharing is what's making me struggle. Currently i have the Data saved as normal vars and display the QR-Code with "react-native-qrcode-svg". For the sharing part I'm using "react-native-share".
The latter is giving me this error:
TypeError: null is not an object (evaluating '_reactNative.NativeModules.RNShare.FACEBOOK')
My Code:
export default function App() {
return (
<View style={styles.container}>
<QRCode
value={JSON.stringify({test: 'testdata'})}
getRef={c => (this.svg = c)}
/>
<TouchableOpacity onPress={this.saveQRCode}>
<View style={styles.instructions}>
<Text>Share QR code</Text>
</View>
</TouchableOpacity>
</View>
);
}
saveQRCode = () => {
this.svg.toDataURL(this.callback);
};
callback = (dataURL) => {
console.log(dataURL);
let shareImageBase64 = {
title: 'React Native',
url: `data:image/png;base64,${dataURL}`,
subject: 'Share Link', // for email
};
Share.open(shareImageBase64).catch(error => console.log(error));
}
Any help is greatly appreciated.
Upvotes: 2
Views: 7307
Reputation: 1
Try to close and rebuild the app using 'react-native run-android'. it worked for me.
Upvotes: 0
Reputation: 125
I have an expo project that's been ejected, and I got past this by stopping metro, running npx pod-install
, and then uninstalling the app from the simulator before firing everything back up.
Also reference these issues for help:
https://github.com/react-native-share/react-native-share/issues/322
https://github.com/react-native-share/react-native-share/issues/837
Upvotes: 0