Skip to content

Reducer is firing twice when adding new todo (video 10) #3

Description

@ApolloTang

@elijahmanor, I am running into some strange issue on video 10 Use the useContext Hook to Wire-up the React Context API

I note that when using useContext hook, a single dispatch of adding new todo will trigger reducer to run twice:

to demonstrate i am logging out the action.type at line 50 in the reducer before the switch statement:

https://github.com/elijahmanor/egghead-course-react-hooks/blob/omega/packages/09-use-the-useContext-hook-to-wire-up-the-react-context-api/src/TodoExample/hooks.js#L50

Screen Shot 2019-08-11 at 8 44 31 PM

below is the animated gif showing log message in console
2019-08-11 20 45 37
notice that reducer fire twice for adding todo, but not for deleting and toggling

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