vmarchesin / react-konami-code

Trigger an easter egg by pressing a sequence of keys.
MIT License
59 stars 13 forks source link

Clear interval and timeout when component unmounts #3

Closed npasqua closed 5 years ago

npasqua commented 5 years ago

Clear the props.timeout and resetDelay interval when component unmounts to prevent the following React error: Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method. https://reactjs.org/docs/react-component.html#componentwillunmount

vmarchesin commented 5 years ago

Hey, sorry for the delay. I'll take a look at the changes this weekend and see if the tests are passing. Thanks for the contribution.

vmarchesin commented 5 years ago

Sorry for the delay. Holidays are coming in and I don't have the time to check this yet. I'll take a look after the new year. Either way this fixes a warning and it's not impeditive.

vmarchesin commented 5 years ago

All good! I always forget to clear the timeouts. Thanks for the contribution, it's a good catch.