React Side-Effects

Learn to add a feature to our Search component in the form of another React hook.

We'll cover the following

We’ll make the Search component remember the most recent search interaction, so the application opens it in the browser whenever it restarts.

First, use the local storage of the browser to store the searchTerm accompanied by an identifier. Next, use the stored value, if a value exists, to set the initial state of the searchTerm. Otherwise, the initial state defaults to our initial state (here “React”) as before:

Get hands-on with 1200+ tech skills courses.