ReduxCasts icon indicating copy to clipboard operation
ReduxCasts copied to clipboard

fix new post connect to state

Open ixigen opened this issue 7 years ago • 2 comments

Hello, after attempting to apply initial values to a redux form I've noticed that it didn't work when I've followed the new post example. The problem was the order in which the components were wrapped.

First we need to wrap the Form component with reduxForm and then connect it to the redux store.

export default reduxForm({ validate, form: "PostsNewForm" })(connect(null, { createPost })(PostsNew));

should be

export default connect(null, { createPost })( reduxForm({ validate, form: "PostsNewForm" })(PostsNew));

ixigen avatar Jun 22 '17 10:06 ixigen

Hey, Check out the Redux Form docs for how they initialize values. Docs

abarlow85 avatar Jun 22 '17 16:06 abarlow85

The docs: connect()(reduxForm()(Form))

The course code had: reduxForm()(connect()(Form))

ixigen avatar Jun 23 '17 08:06 ixigen