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

garbage/memory collection #12

Closed
curist opened this issue May 13, 2014 · 3 comments
Closed

garbage/memory collection #12

curist opened this issue May 13, 2014 · 3 comments

Comments

@curist
Copy link

curist commented May 13, 2014

If a component have setInterval to update itself's state,
it won't be garbage collected.
As far as I know, this is related to how javascript handle an object's life cycle,
so... any insight on this?

demo gist: https://gist.github.com/curist/10a90d741277369196e7

@andreypopp
Copy link
Owner

Start timer in componentDidMount as componentWillMount is not symmetric to componentWillUnmount (the former will be executed on server while the latter won't).

@andreypopp
Copy link
Owner

P.S. This is not (directly) related to garbage collection but to how React lifecycle works.

@curist
Copy link
Author

curist commented May 13, 2014

ah, thx for the quick reply! Thought I should wrap things in if(!isServer). Using componentDidMount sure be much better!

BTW, thanks so much for this handy library +1

@curist curist closed this as completed May 13, 2014
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