React useEffect and localStorage doesn’t set state that is required in child components
I’ve got an app with rudimentary localStorage saving working, but I’m running into a problem when trying to load that data. const defaultSaveState=”default”; const [currentSave, setCurrentSave] = useState(defaultSaveState); useEffect(() => { setCurrentSave(JSON.parse(localStorage.getItem(“save”)) // ‘saved data’ }, []) console.log(currentSave); // outputs ‘default’ This runs in the parent component and the currentSave state is passed to a … Read more