Created
December 5, 2025 11:56
-
-
Save nodomw/891f7391be0b75b6e4cd9822cd2b4a0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useState, useEffect } from "react"; | |
| import "./App.css"; | |
| function Store() { | |
| const [form, setForm] = useState( | |
| window.localStorage.getItem("form"), | |
| ); | |
| useEffect(() => { | |
| window.localStorage.setItem( | |
| "form", | |
| form ?? "", | |
| ); | |
| }, [form]); | |
| return ( | |
| <input | |
| className="input" | |
| value={form ?? ""} | |
| onChange={(e) => setForm(e.target.value)} | |
| /> | |
| ); | |
| } | |
| export default Store; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment