Fix “Cannot perform a React state update on an unmounted component” warning

Every React developer would have experienced the following error when working with React. It happens if one performs a state update (call setState) on a component that has been unmounted. React warns us that this causes memory leaks. Although it is just a warning, it is necessary to fix it to avoid these kinds of memory leaks.