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

[AutoComplete] setState called even when component unmounted #4867

Closed
ghost opened this issue Aug 1, 2016 · 7 comments
Closed

[AutoComplete] setState called even when component unmounted #4867

ghost opened this issue Aug 1, 2016 · 7 comments
Labels
bug 🐛 Something doesn't work component: autocomplete This is the name of the generic UI component, not the React module!

Comments

@ghost
Copy link

ghost commented Aug 1, 2016

[AutoComplete]:SetState Called even when component unmounted

on handleNewRequest mounted new component

Versions

  • Material-UI: 0.15.2
  • React: 0.14.6
  • Browser: Chrome 51.0.2704.103

I have autocomplete of which handleNewRequest event I am mounting a new component.I get a error that its called setState for searchText.How do I Prevent this.

I have tried to call setState on componentWillUnmount by taking the searchText in my state.Still not solved

Images & references

error

It has something to do with timerTouchTapCloseId.
it calls

_this.setState({
   searchText: searchText
});

which it cannot find once unmounted

@chenwei0104
Copy link

+1

@ghost
Copy link
Author

ghost commented Aug 3, 2016

I have a workaround.If we add a delay of 100ms it works fine.

@oliviertassinari
Copy link
Member

@dhruvdatt I have noticed the same thing when playing with the AutoComplete. I haven't investigated much. Looks like one of the componentWillUnmount method isn't clearing the asynchronous dependencies correctly.

@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Aug 3, 2016
@oliviertassinari oliviertassinari changed the title [AutoComplete]:SetState Called even when component unmounted [AutoComplete] setState called even when component unmounted Aug 3, 2016
@dbroadhurst
Copy link

I'm seeing the same issue when I navigate from a screen using the onChange method on a DropDown menu

@avocadowastaken
Copy link
Contributor

avocadowastaken commented Sep 23, 2016

This problem comes from Popover, some race condition problem.

Maybe it's good idea to not maintains stuffs like that and focus on main the thing UI and let third party libs maintain positioning and visibility. I found react-overlays super useful

@chrisshiplet
Copy link

chrisshiplet commented Oct 14, 2016

Running into this issue as well. setTimeout callbacks like the one in Popover that call setState on a component should always be referenced on the component instance (something like this.timer), so you can call clearTimeout(this.timer) when the component unmounts. Otherwise the callback will try to update state after the component is gone.

Related: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html

@oliviertassinari
Copy link
Member

Closed by #4783

@oliviertassinari oliviertassinari added the component: autocomplete This is the name of the generic UI component, not the React module! label Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: autocomplete This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

5 participants