|
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 :)
mern-tutorial/frontend/src/pages/Dashboard.jsx
Lines 27 to 31 in 48ac3db
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 :)