Last active
December 24, 2019 17:13
-
-
Save rluena/a1d414827d1593b0e0d2907b1fb6c73c to your computer and use it in GitHub Desktop.
redux-form multiple component using similar name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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