-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Labels
Description
Steps to reproduce the issue:
- Create a toaster with state inside a simple View.
- Run an event (clicking on a button for example).
- On event created, set the state with the desired message.
- After the message shows up on screen, exit the component (back button on navigator for example).
- After a while, a warning message shows up:
Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op.
Example code to reproduce the issue:
constructor(props) {
super(props);
this.state = {
toast: {}
};
}
submitAction() {
if (this.formIsNotValid) {
this.setState({
toast: {
text: 'The form is not valid!',
styles: ToastStyles.error
}
});
}
}
renderMessage() {
if (!_.isEmpty(this.state.toast)) {
return <Toaster message={this.state.toast} />;
}
return <View />;
}
render() {
return (
<View>
{this.renderMessage()}
<TouchableOpacity
style={s.buttonContainer}
onPress={() => this.submitAction()}>
<Text style={s.button}>Submit</Text>
</TouchableOpacity>
</View>
)
}
package.json:
"dependencies": {
"lodash": "^4.17.4",
"moment": "^2.18.1",
"react": "16.0.0-alpha.12",
"react-native": "0.48.2",
"react-native-camera": "^0.10.0",
"react-native-config": "^0.7.0",
"react-native-datepicker": "^1.6.0",
"react-native-fs": "^2.8.1",
"react-native-htmlview": "^0.12.0",
"react-native-image-gallery": "^2.0.0",
"react-native-navigation": "^1.1.228",
"react-native-tab-view": "0.0.69",
"react-native-toaster": "^1.1.2",
"react-native-vector-icons": "^4.3.0",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
}