Auto Save Text
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
Companies:
Solve Similar questions 🔥
Want to upskill? Explore our courses!
Namaste DSA
Master DSA from scratch with numerous problems, and expert guidance.
Namaste React
Wanna dive deep into React and become Frontend Expert? Learn with me now!
Namaste Frontend System Design
The most comprehensive and detailed course for frontend system design.
Namaste Node.js
Wanna dive deep into Node.js? Enroll into `Namaste Node.js` now!
