davidkpiano / react-redux-form

Create forms easily in React with Redux.
https://davidkpiano.github.io/react-redux-form
MIT License
2.06k stars 251 forks source link

Reading state from ArrayMapNode #1105

Open jasenkoh opened 6 years ago

jasenkoh commented 6 years ago

Hi,

I'm using react-boilerplate and I'm unable to make rrf to work in elegant way as I would like to. I found root cause (at least looking at how it works on rrf examples). mapStateToProps in fieldset-component.js state is map of forms e.g.

image

However, in my bolierplate app, forms state is in an array of state nodes, which failes for rrf to read actual form from it.

This is state value received in mapStateToProps

image

If I do state = state.get('forms') than I'll get expected map of objects otherwsie I'll end up with error: Unable to create Form component. Could not find form for "dynamic.user" in the store.

Here's my setup:

reducer/forms.js

const initialUserState = fromJS({
  name: ''
});

export default combineForms({
  user: initialUserState
}, 'dynamic');

mainReducer.js

export default function createReducer(injectedReducers) {
  return combineReducers({
    ...rootReducer,
    ...injectedReducers
  });
}

store.js

  const middlewares = [
    sagaMiddleware,
    thunk,
    routerMiddleware(history)
  ];

  const enhancers = [
    applyMiddleware(...middlewares)
  ];

  const store = createStore(
    createReducer(),
    fromJS(initialState),
    composeEnhancers(...enhancers)
  );
nwflte commented 5 years ago

Have you found a solution? Please let me know because I'm having the same issue