I've never worked with local storage in combination with React.
My goal is simple: When users complete a test, localstorage should store a value saying they've completed the test. If the completedTest State is true, show a ShowResultsComponent.
Showhow I feel as if I'm going about this the incorrect way.
// I'd like localStorage.complete to start as false.
const [completedTest, setCompletedTest] = useState(localStorage.complete);
useEffect(() => {
localStorage.getItem('complete');
}, []);
const completeTest = () => {
localStorage.setItem('complete', true);
}
{completedTest ?
<ShowResultsComponent />
: null }