FinanceReactNative
FinanceReactNative copied to clipboard
Warning: Can only update a mounted or mounting component.
I check out master branch and try to run the ios version and get warning:
Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component.
The stack trace points to stock-cell.js
line 84 and 92.
componentDidMount() {
StockStore.listen(state => this.onStockStoreChange(state));
}
componentWillUnmount() {
StockStore.unlisten(state => this.onStockStoreChange(state));
}
onStockStoreChange(state) {
this.setState({
selectedProperty: state.selectedProperty,
selectedStock: state.selectedStock,
});
}
And the stock price is empty.
I've tried one of solutions on stack overflow that using ref, but it didn't work for me. Could someone look into it? Thanks!
alright, I replace three method in the stack trace above by
StockStore.listen(this.onStockStoreChange);
}
componentWillUnmount() {
StockStore.unlisten(this.onStockStoreChange);
}
onStockStoreChange() {
this.setState({
selectedProperty: this.state.selectedProperty,
selectedStock: this.state.selectedStock,
});
}
and add this.onStockStoreChange = this.onStockStoreChange.bind(this);
in the constructor, then there's no warnings. But stock price is still empty though.
why?can anyone help us?