Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 0830e45

Browse files
committed
Updating quickstart guide for existing stores/reducers. Fixes #845
1 parent 82691aa commit 0830e45

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

docs/guides/quickstart.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,54 @@ import {
5858
createStore,
5959
applyMiddleware
6060
} from 'redux';
61-
import { combineForms } from 'react-redux-form';
61+
import {
62+
combineForms,
63+
createForms // optional
64+
} from 'react-redux-form';
6265

6366
const initialUserState = {
6467
firstName: '',
6568
lastName: ''
6669
};
6770

71+
// If you want your entire store to have the form state...
6872
const store = createStore(combineForms({
6973
user: initialUserState,
7074
}));
7175

76+
// Or you have an existing store and want the form state to
77+
// exist alongside the existing state...
78+
const store = 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+
const store = 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+
72104
export default store;
73105
```
74106

107+
See [`createForms`](../api/createForms.html) and [`combineForms`](../api/combineForms.html) for more info on adding RRF to existing stores.
108+
75109
**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`.
76110

77111
### 4. Setup your form!

0 commit comments

Comments
 (0)