Skip to content

Instantly share code, notes, and snippets.

@rluena
Last active December 24, 2019 17:13
Show Gist options
  • Save rluena/a1d414827d1593b0e0d2907b1fb6c73c to your computer and use it in GitHub Desktop.
Save rluena/a1d414827d1593b0e0d2907b1fb6c73c to your computer and use it in GitHub Desktop.
redux-form multiple component using similar name
// Link to the issue addressed
https://github.com/redux-form/redux-form/issues/603#issuecomment-295043224
// FormContainer
import Form from './Form';
....
class FormContainer extends Component
{
onSubmit (data, dispatch) {...}
render() {
return <Form {...this.props} onSubmit={onSubmit} />
}
}
// it's important in this case to note that mapStateToProps can have a second parameter, which is the props passed down
// from the calling (parent) component
function mapStateToProps(state, props) {
const someOtherDataFromStore = state.someOtherDataFromStore ;
return {
form: props.formId,
someOtherDataFromStore,
};
}
export default connect(mapStateToProps)(FormContainer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment