Christian
Christian

Reputation: 7419

Values are not rendered using redux-form

before I write this, I tried everything to find a solution, but actually nothing worked. I have a standard react/redux app. (Both of the libs are at the latest version.)

Now I wanted to use redux-form to control my forms. I've added the redux-form reducer and copied the "Simple Form" into my app. I can see that on change redux actions are being fired, but the value of the input fields will never be rendered. Also the actions contains always just the last character that I typed.

I really would like to provide code, but for some reason, the code on your website seems to work. Is there some known reason that an input value is not rendered? I am sure the onChange action is being called.

Oh and I should mention that onBlur, the whole value get's deleted from the store.

EDIT: I've removed all other reducer, middleware and stuff for testing. Still the same results

Upvotes: 0

Views: 328

Answers (1)

rafaelbiten
rafaelbiten

Reputation: 6240

I think I just found the solution to this problem and it's a little bit stupid =/

Here's what I had:

import { combineReducers } from 'redux';
import { reducer as forms } from 'redux-form';

import otherReducer from './otherReducer';

export default combineReducers({ otherReducer, forms });

Notice that I was importing redux-form reducer as forms and passing it as is to my combineReducers (like I did with otherReducer) using ES6 Object property value shorthand.

The problem is that the key used to pass redux-form reducer to our combineReducers MUST be named form, so we have to change it to:

export default combineReducers({ customer, form: forms });

or

import { reducer as form } from 'redux-form';
export default combineReducers({ otherReducer, form });

Hope this helps... I only wish their documentation were more clear about this.

Upvotes: 3

Related Questions