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
*Requirements: [reducer](https://www.robinwieruch.de/javascript-reducer/) and [useReducer](https://www.robinwieruch.de/react-usereducer-hook/) explained.
10
10
11
11
## Installation
12
12
13
13
`npm install use-combined-reducers`
14
14
15
15
## Usage
16
16
17
+
Create a global dispatch function and state object by initializing multiple `useReducer` hooks in `useCombinedReducers`:
18
+
17
19
```
20
+
import React from 'react';
18
21
import useCombinedReducers from 'use-combined-reducers';
19
22
20
23
const App = () => {
@@ -27,6 +30,64 @@ const App = () => {
27
30
28
31
...
29
32
}
33
+
34
+
export default App;
35
+
```
36
+
37
+
You can pass state and dispatch function down via [props](https://www.robinwieruch.de/react-pass-props-to-component/) or [React's Context API](https://www.robinwieruch.de/react-context-api/). Since passing it down with props is straight forward, the approach with context is demonstrated here. In some file:
0 commit comments