TypeError: Cannot read property 'show' of undefined
seclace opened this issue · comments
Vadim Goldenko commented
Hi. I installed this package with npm i --save react-native-safari-view
and then use it in my component:
...
import SafariView from 'react-native-safari-view';
...
pressHandler = () => {
SafariView.show({ url: this.props.webviewUrl })
.then((bool) => { console.log('available', bool); })
.then(SafariView.show({
url: this.props.webviewUrl,
}))
.catch(error => {
console.log('error:', error);
});
};
...
render() {
return (
<View style={styles.root}>
<TouchableOpacity
style={{ borderWidth: 1, alignItems: 'center', padding: 20 }}
onPress={this.pressHandler}>
<Text>Press</Text>
</TouchableOpacity>
</View>
);
}
And get this error:
TypeError: Cannot read property 'show' of undefined
at SafariViewManager.ios.js:27
at tryCallTwo (core.js:45)
at doResolve (core.js:200)
at new Promise (core.js:66)
at Object.show (SafariViewManager.ios.js:26)
at Object.Cart._this.pressHandler [as onPress] (Cart.js:77)
at Constructor.touchableHandlePress (TouchableOpacity.js:119)
at Constructor.proxiedMethod [as touchableHandlePress] (createPrototypeProxy.js:44)
at Constructor._performSideEffectsForTransition (Touchable.js:715)
at Constructor.proxiedMethod [as _performSideEffectsForTransition] (createPrototypeProxy.js:44)
I logged the NativeModules object imported from react-native and it has not SafariViewManager property (== undefined).
May be I missed something?
RN version is 0.31
I ran node node_modules/react-native/local-cli/cli.js link
and did't get any effect from this.
Vadim Goldenko commented
I've tested these steps with RN 0.42.3 and it worked fine.
Vadim Goldenko commented
I needed to rebuild.