You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
The text was updated successfully, but these errors were encountered: