Talor-A / react-native-message-bar

A notification bar alert displayed at the top of the screen for react-native
MIT License
55 stars 27 forks source link

Can only Update a mounting and mounted component [not working with react-navigation] #25

Closed malonguwa closed 6 years ago

malonguwa commented 6 years ago

Issue: Can only Update a mounting and mounted component. This usually means you called setState or the forceUpdate on the unmounted component. This is a no-op. Please check the code for the MessageBar Component.

Registered and unregistered MessageBarManager as is it is shown in demo. But when coming back from navigated screen, this warning shows up and Alert message does not shows then. https://github.com/Talor-A/react-native-message-bar/issues/22

@Talor-A I saw your answer for this issue, but could you show some example how to fix this with react-navigation?

For example, in my App, I am using StackNavigator as the root component in App.js. App.js

 render() {
            return <LoginStackNavigator screenProps={screenProps} />;
   }

LoginStackNavigator.js

export const LoginStackNavigator = StackNavigator({
    LoginScreen: {
        screen: LoginScreen,
        navigationOptions : {
            header:null
        }
    },     
   SignUpScreen: {
        screen: SignUpScreen,
        navigationOptions : {
            header:null
        }
    }}

How to put message bar component outside of the stacknavigator? And what should I do in different Screen [such as LoginScreen and SignUpScreen which inside the StackNavigator] to use the MesageAlert?

The example is not working with react-navigation.

Thanks a lot