To declare an effect. It allows you to perform certain actions in response to component updates, such as fetching data, subscribing to events, or manually manipulating the DOM.
The main reason to use the return value from the effect’s logic funtion is to ensure that any side effects initiated by the ‘effect’ are properly disposed of. It’s important for maintaining an efficient app and preventing memory leaks especially when used with long-lived components or components the mount and unmount frequently.
Bookmark and Review Keep these pages handy - they answer questions that show up regularly for this lab.
Responding to Events Conditional Rendering Updating Arrays in State Updating Objects in State
Being able to use the ‘useEffect’ appropriately, it has a lot of aspects too it, all of which seem helpful, as long as it’s used properly.