React hooks state variable not updating after rerender
You can try with useEffect which will give updated state whenever there will be update.
useEffect(() => {
saveFruits();
}, [fruits]);
You can try with useEffect which will give updated state whenever there will be update.
useEffect(() => {
saveFruits();
}, [fruits]);