我在 React native 中遇到了这个问题。 如何通过 react-navigater 将多个方法从一个组件传递到另一个组件。
实际上,我知道 Redux 或 Mobx 是解决这个问题的更好方法,但我老板出于某种原因不能那样做...
所以,请告诉我这一点。
示例代码是这样的。
method1() {
this.setState({ checked: true });
}
method2() {
this.setState({ marked: false });
}
navigation={this.props.navigation.navigate('Home',
{ method1: this.method1.bind(this);},
{ method2: this.method2.bind(this);},
)}
我想做上面的,但我做不到。
最佳答案
尝试将您的数据作为单个第二个参数传递:
navigation={
this.props.navigation.navigate('Home',
{ method1: this.method1.bind(this),
method2: this.method2.bind(this)}
)}
关于javascript - 如何通过 React-navigation 将多个方法从一个组件传递到另一个组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53051881/