Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: Can only update a mounted or mounting component. #25

Open
b27lu opened this issue Dec 1, 2017 · 2 comments
Open

Warning: Can only update a mounted or mounting component. #25

b27lu opened this issue Dec 1, 2017 · 2 comments

Comments

@b27lu
Copy link

b27lu commented Dec 1, 2017

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!

@b27lu
Copy link
Author

b27lu commented Dec 1, 2017

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.

@wylhit1985
Copy link

why?can anyone help us?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants