You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everybody, in my react app, I dispatch an action to update the state in the reducer. But my component just re-render unless I use yield delay with my action.
Here is my saga: export function* TestSagaFunc() { try { yield put({ type: actions.TEST_DONE }); } catch (error) { console.log(error); } }; export default function* rootSaga() { yield all([ yield takeEvery(actions.TEST, TestSagaFunc) ]); };
This doesn't work, the component not re-render: export function* TestSagaFunc() { yield put({ type: actions.TEST_DONE }); };
This work: export function* TestSagaFunc() { yield delay(0); yield put({ type: actions.TEST_DONE }); };
What was I missing? Thank for watching.
This discussion was converted from issue #2165 on March 12, 2021 11:41.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everybody, in my react app, I dispatch an action to update the state in the reducer. But my component just re-render unless I use yield delay with my action.
Here is my saga:
export function* TestSagaFunc() { try { yield put({ type: actions.TEST_DONE }); } catch (error) { console.log(error); } }; export default function* rootSaga() { yield all([ yield takeEvery(actions.TEST, TestSagaFunc) ]); };
This doesn't work, the component not re-render:
export function* TestSagaFunc() { yield put({ type: actions.TEST_DONE }); };
This work:
export function* TestSagaFunc() { yield delay(0); yield put({ type: actions.TEST_DONE }); };
What was I missing? Thank for watching.
Beta Was this translation helpful? Give feedback.
All reactions