-
简而言之,这绝对是一种不寻常的反应模式,不是很多人会推荐的。导入
let
更明智的做法是
customersData
到父组件的
state
把它传给
CustomersSearch
通过一个道具。
export default class Home extends Component {
constructor (props) {
super(props);
this.state = { customersData: null };
this._getAllCustomers = this._getAllCustomers.bind(this)
}
render() {
return (
<JumboButton
onPress={() => {
this.props.navigator.push({
component: props =>
<CustomerSearch customersData={this.state.customersData} {...props} />
});
}}
>
);
}
_getAllCustomers(limit, sortAttr, order) {
apiCall.(apiUrl, {
...
}).then((responseData) => {
const customersDataAll = responseData.data;
const customersData = customersDataAll.filter((f) => {
return f.lastname !== ''
});
this.setState({ customersData });
});
}
}
不知道你的
JumboButton
的
onPress
道具确实管用,但你应该明白吗?