react native 怎么在调用父组件的方法

2025-04-24 09:39:03
推荐回答(1个)
回答1:

你去好好看一下React组件生命周期这一部分。你可以在子组件添加一个componentWillRecieveProps周期,在里面获取到即将接收的props。如下: componentWillReceiveProps(nextProps) { this.setState({ A: nextProps.A }); }