Facebook Pixel

Auto Save Text

React.js
easy
15 mins

Build an input field that automatically saves whatever the user types into localStorage by the name "autosave-text", and restores it even after a page refresh. Include a Clear button to reset both the input and the stored value.

Things to do

  • Create a text input where the user can type anything.
  • Whatever the user types should be saved automatically.
  • On page refresh, the input should restore the previously saved text.
  • Add a Clear button that clears the text input.
  • Add a Clear button Removes the saved value.
  • The input must be fully controlled by React state.

Example

User types:

Hello World

They refresh the page Input should still show:

Hello World
  • User clicks Clear
  • Input becomes empty
  • Stored value is removed.

Testing Instructions

  • Please use the following data-testid attributes in your React component:

  • input-field → for the text input

  • clear-btn → for the clear button input

Preview what you need to build

Companies:

Atlassian
amazon
zomato

Solve Similar questions 🔥

Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.