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
{{ message }}
This repository was archived by the owner on Aug 23, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: docs/guides/quickstart.md
+35-1Lines changed: 35 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,20 +58,54 @@ import {
58
58
createStore,
59
59
applyMiddleware
60
60
} from'redux';
61
-
import { combineForms } from'react-redux-form';
61
+
import {
62
+
combineForms,
63
+
createForms// optional
64
+
} from'react-redux-form';
62
65
63
66
constinitialUserState= {
64
67
firstName:'',
65
68
lastName:''
66
69
};
67
70
71
+
// If you want your entire store to have the form state...
68
72
conststore=createStore(combineForms({
69
73
user: initialUserState,
70
74
}));
71
75
76
+
// Or you have an existing store and want the form state to
77
+
// exist alongside the existing state...
78
+
conststore=createStore(combineReducers({
79
+
existing: existingReducer,
80
+
foo: fooReducer,
81
+
bar: barReducer,
82
+
83
+
// ... use createForms, which will create:
84
+
// the model reducer at "user"
85
+
// the forms reducer at "forms" (e.g., "forms.user")
86
+
...createForms({
87
+
user: initialUserState,
88
+
}),
89
+
}));
90
+
91
+
// Or you want to nest your form and model reducer under a specific key...
92
+
conststore=createStore(combineReducers({
93
+
existing: existingReducer,
94
+
foo: fooReducer,
95
+
bar: barReducer,
96
+
97
+
// Make sure to specify the key as the second argument, so that RRF
98
+
// knows where the form and model reducers exist in the store!
99
+
myForms:combineForms({
100
+
user: initialUserState,
101
+
}, 'myForms'),
102
+
}));
103
+
72
104
exportdefaultstore;
73
105
```
74
106
107
+
See [`createForms`](../api/createForms.html) and [`combineForms`](../api/combineForms.html) for more info on adding RRF to existing stores.
108
+
75
109
**Note:**`redux-thunk` is no longer required for RRF versions 1.3.0 and higher. If you are using a previous version, make sure to configure your store to use `redux-thunk`.
0 commit comments