Posts

Showing posts from October, 2023

Memory Leaks in ReactJs

Image
Memory leak can be understand like program engaging memory for unused data. Data is stored in memory but not used by and program. memory leak warning React developer can understand by these given examples likes: 1. DOM Event Listener Let's suppose we define any event handler on component mount but forgot to define remove event listener  on component unmount. When component unmount this listener still present in memory but as unused handler.  So it is recommended to always define remove event listener on component unmount or clean up callback. see the below code sample for an idea. const MyComponent = () => {                             useEffect (() => {                 ...