【发布时间】:2020-01-24 11:57:02
【问题描述】:
我正在使用 react-native-router-flux 并将地址传递给前一个组件。值通过,但我收到警告 Can't perform a React state update on an unmounted 要修复,请取消 componentWillUnmount 方法中的所有订阅和异步任务。
class ChangeAddress extends Component {
constructor(props) {
super(props);
this.state = {
text:''
};
this.handleChange = this.handleChange.bind(this);
}
onPressNext =() => {
Actions.replace('Navigate', {text:this.state.text});
}
handleChange(text) {
this.setState({ text: text });
}
render() {
return(
<View>
<TextInput
placeholder="Enter Address"
onChangeText={this.handleChange }
/>
<Button title =" Save Address" onPress={this.onPressNext} />
</View>
);
}
}
export default ChangeAddress;```
【问题讨论】:
标签: reactjs react-native reactjs-flux react-native-router-flux