-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
tutorial: In the onDestroy example, explicitly show the memory leak #5515
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
tutorial: In the onDestroy example, explicitly show the memory leak #5515
Conversation
This contains a superset of the code in #5513 |
This reverts commit 159cf86.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea of visualising the memory leak is good.
probably a few suggestions over here to make it better:
- probably update the instructions as well, to explain what we are seeing (the timer still ticking even though the component is unmounted), and why is it wrong / bad
- actually another way of visualising the memory leak would be to have a
console.log
, but i think either way is fine for me. - probably name the inner component with a better name, such as
Timer
instead ofInner
. try make it more friendly and real. - same thing goes for the
counter=1
, something more friendly, like the current message, such as"The component has been created since 5 seconds"
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
In the onDestroy example, the current solution does not explicitly (visually) show the memory leak and the moment when the component was destroyed.
If I remove the onDestroy block in the utils.js file on the site, nothing visually changes. It will not be clear if the callback has been executed.
I decided to make a more illustrative example in my opinion, what do you think about it?
Demo repl
Before submitting the PR, please make sure you do the following
Tests
npm test
and lint the project withnpm run lint