React-native-paper: Cannot render Snackbar

Created on 6 Jul 2018  路  2Comments  路  Source: callstack/react-native-paper

Current behavior

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 !

Expected behavior

Should not throw error?

Code sample

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;

Your Environment

| 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

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 StyleSheet from react-native instead.

All 2 comments

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 :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZhengYuTay picture ZhengYuTay  路  3Comments

ferrannp picture ferrannp  路  4Comments

timothystewart6 picture timothystewart6  路  4Comments

alikazemkhanloo picture alikazemkhanloo  路  4Comments

sm2017 picture sm2017  路  4Comments