I call this function on every button click.
the problem is when the button first clicked it doesn't save the first element until next clicks so the first element never get saved
const add=()=>{ if(website){ setInfo([...info,{website:website,password:generate()}]) localStorage.setItem("data",JSON.stringify(info)); } } state info:
const[info,setInfo]=useState([])