Learn-React-In-30-Minutes
Learn-React-In-30-Minutes copied to clipboard
Changes to be made in App.js
-
the import of uuid should now say (according to their readme)
import { v4 as uuidv4 } from 'uuid';
-
There is a problem with the react.strictMode in that the code in de video doesn't restore the todos from storage correctly.
Although removing strictmode solves it, I also watched your react hooks video in which you explain how to correctly call the setState functions and why it otherwise doesn't do what you might expect when called more than once.
So it seems in this case the setTodos in the useEffect that initializes the todo's should say:
setTodos( prevTodos => [...prevTodos, ...storedTodos] );
instead of
setTodos(storedTodos)
After that change the function will restore the todos even in strictmode.