Skip to content

Infinite Loop #3

Description

@N3OGeorgy

dispatch(getGoals())
return () => {
dispatch(reset())
}

I am a newbie in react but there is a infinite loop issue if dispatch(getGoals()) gets rejected.
The new state will be state.isError = true from extraReducers getGoals.rejected.
Then dispatch(reset()) comes and sets the state state.isError = false, component renders again and the loop starts again.

My fix:
dispatch(getGoals()) if(!isError){ dispatch(reset()) }

If someone can come with a linked explanation with the exact reason why this is happening would be great :)

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