Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 5597bc4

Browse files
authored
Update README.md
1 parent a2ab665 commit 5597bc4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ const myReducer = ([state], event) => {
8989
}
9090

9191
// in your component
92-
const [allState, dispatch] = useReducer(myReducer);
92+
const [[state, effects], dispatch] = useReducer(myReducer);
9393

9494
useEffect(() => {
95-
allState.effects.forEach(effect => {
95+
effects.forEach(effect => {
9696
// execute the effect
9797
});
98-
}, [allState.effects]);
98+
}, [effects]);
9999
```
100100

101101
Instead of being implicit about which effects are executed and _when_ they are executed, you make this explicit in the "effect reducer" with the helper `exec` function. Then, the `useEffectReducer` hook will take the pending effects and properly execute them within a `useEffect()` hook.

0 commit comments

Comments
 (0)