Skip to content

Commit f5d10f1

Browse files
authored
Scaling Up with Reducer and Context
1 parent 8d7a517 commit f5d10f1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,22 @@ On this page you learned:
311311
<br>
312312

313313

314+
### Scaling Up with Reducer and Context
315+
316+
## Recap[](https://react.dev/learn/scaling-up-with-reducer-and-context#recap "Link for Recap")
317+
318+
- You can combine reducer with context to let any component read and update state above it.
319+
- To provide state and the dispatch function to components below:
320+
1. Create two contexts (for state and for dispatch functions).
321+
2. Provide both contexts from the component that uses the reducer.
322+
3. Use either context from components that need to read them.
323+
- You can further declutter the components by moving all wiring into one file.
324+
- You can export a component like `TasksProvider` that provides context.
325+
- You can also export custom Hooks like `useTasks` and `useTasksDispatch` to read it.
326+
- You can have many context-reducer pairs like this in your app.
327+
328+
*link: https://react.dev/learn/scaling-up-with-reducer-and-context*
329+
330+
<br>
331+
332+

0 commit comments

Comments
 (0)