flexdinesh / react-socks

🎉 React library to render components only on specific viewports 🔥
MIT License
426 stars 29 forks source link

Debounce should cancel in ComponentWillUnmount #14

Closed nutboltu closed 5 years ago

nutboltu commented 5 years ago

https://github.com/flexdinesh/react-socks/blob/fdd4cc19960ac4d16bed8184f79b8c7fa69c1f0d/src/Breakpoint/BreakpointProvider.js#L30

In BreakpointProvider, the lodash debounce should be cancel on ComponentWillUnmount. Otherwise it will cause a memory leak when user resize the window and unmount the component within 100 ms (debounce delay time)

flexdinesh commented 5 years ago

@nutboltu Can you explain with an example code? Would help if you could link to some resources explaining this.

nutboltu commented 5 years ago

@flexdinesh I opened a PR with the issue. It might help you to understand