Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to be made in App.js #21

Open
SharathVaddireddy opened this issue Mar 26, 2024 · 0 comments
Open

Changes to be made in App.js #21

SharathVaddireddy opened this issue Mar 26, 2024 · 0 comments

Comments

@SharathVaddireddy
Copy link

  1. the import of uuid should now say (according to their readme)

    import { v4 as uuidv4 } from 'uuid';

  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant