Level 1 Challenge LightHouse SESL
A couter that increases when the button is clicked and does not revert to the initial count when the page is refreshed
Screenshot of the mockup
Link to live site:-
Used localstorage
to ensure that the count
state does not revert to 0
when the page is refreshed
const [count, setCount] = useState(localStorage.getItem("yourCount") || 0);
useEffect(() => {
localStorage.setItem("yourCount", count);
}, [count]);
<button onClick={() => setCount((count) => JSON.parse(count) + 1)} > Click Here</button>