Local Storage I

Easy
10
1
58.2% Acceptance

Write a simple App component that returns an input field of type text. Users can interact with the input field to type in any string they want. You’re meant to store this string in local storage so that every time when the page reloads it pre-fills the input field with the latest known value for the users.
We have already written some starting code for you.
image

Instructions

  • Do not edit the data-testid attributes.
  • Use the reload button in the demo browser to test if your component works as expected.
  • Use key inputValue to store the data in local storage.

Hints

  • You can use the setItem and getItem methods available on the global localStorage object to save and read data.
  • You can make input a controlled element by saving the current value in the state using useState hook.
  • On the first app load, you can initialise the state to the value found in local storage, if no such value is found, then make it an empty string.