Skip to content

Instantly share code, notes, and snippets.

@nodomw
Created December 5, 2025 11:56
Show Gist options
  • Select an option

  • Save nodomw/891f7391be0b75b6e4cd9822cd2b4a0e to your computer and use it in GitHub Desktop.

Select an option

Save nodomw/891f7391be0b75b6e4cd9822cd2b4a0e to your computer and use it in GitHub Desktop.
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