When trying to render snackbar, I get an error "Cannot read property 'mount' of null"
The error is thrown in PortalConsumer.js
componentDidMount() {
this._key = this.props.manager.mount(this.props.props);
}
because manager == null;
Thanks for any assistance !
Should not throw error?
import { View, Text, StyleSheet } from 'react-native';
import { Snackbar } from 'react-native-paper';
render() {
return (
<View style={styles.app}>
<Switch>
<Route exact path="/" component={LoginContainer} />
</Switch>
<Snackbar
duration={3000}
visible={this.state.open}
onDismiss={() => this.handleClose()}>
{this.state.disableTranslation ? this.state.message : I18n.t(this.state.message)}
</Snackbar>
</View>
);
}
The documentation also specifies to import
import { Snackbar, StyleSheet } from 'react-native-paper';
But StyleSheet is not exported by react-native-paper;
| software | version
| --------------------- | -------
| ios or android | Android 28
| react-native | 0.55.4
| react-native-paper | 1.11.0
| node | 8.10.0
| npm or yarn | 6.1.0
Did you follow https://callstack.github.io/react-native-paper/getting-started.html before and wrapped your app with PaperProvider?
For the second issue import StyleSheet from react-native instead.
Hey, just 5 seconds before you commented I realized my mistake.
Yes, I was missing the PaperProvider wrapper. But thanks anyway :)
Most helpful comment
Did you follow https://callstack.github.io/react-native-paper/getting-started.html before and wrapped your app with
PaperProvider?For the second issue import
StyleSheetfromreact-nativeinstead.