Issue
I'm using ngrx-forms (specifically the ngrx 8 syntax) to sync my form and state store. The form state updating actions are successfully dispatched e.g.
{
controlId: 'adForm.location.community',
value: 'wst',
type: 'ngrx/forms/SET_VALUE'
}
However, the state always stays the same, the above produces no diff in the Redux dev tools.
My reducer looks as follows:
export const reducer = createReducer(
initialAdFormStoreState,
onNgrxForms(),
// Other action handlers
// ...
)
export const adFormReducer = wrapReducerWithFormStateUpdate(
reducer,
(s) => s.data.form,
adFormValidators,
)
The initial state is created as follows:
const initialAdFormStoreState: AdFormStoreState = {
data: {
form: createFormGroupState<AdForm>('adForm', { /* ... */ })
// ...
},
// ...
}
I've checked the updating state documentation countless times and everything looks correct.
Solution
onNgrxForms()
only checks for forms at the top level of the feature state object. It wasn't updating my state because I had the form at data.form
since we split state into ui/data. I had to hoist it up a level. Alternatively you can write your own implementation of onNgrxForms()
.
Answered By - Moo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.