Skip to content

Changes to be made in App.js #21

Description

@SharathVaddireddy
  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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions