-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
44 additions
and
35 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
import React, { Component } from "react"; | ||
import { updateNameField, createUser } from "./actions"; | ||
import { createUser } from "./actions"; | ||
import { connect } from "react-redux"; | ||
import { Field, reduxForm } from "redux-form"; | ||
|
||
class UserCreator extends Component { | ||
updateNameField = event => { | ||
this.props.updateNameField(event.target.value); | ||
}; | ||
createUser = event => { | ||
event.preventDefault(); | ||
this.props.createUser(); | ||
createUser = user => { | ||
this.props.createUser(user); | ||
}; | ||
render() { | ||
const { name } = this.props; | ||
const { handleSubmit } = this.props; | ||
return ( | ||
<form onSubmit={this.createUser}> | ||
<form onSubmit={handleSubmit(this.createUser)}> | ||
<h3>User creator</h3> | ||
<input type="text" value={name} placeholder="name" onChange={this.updateNameField} /> | ||
<Field name="name" component="input" type="text" placeholder="name" /> | ||
<button>Save</button> | ||
</form> | ||
); | ||
} | ||
} | ||
|
||
const mapStateToProps = state => ({ name: state.name }); | ||
const mapStateToProps = state => ({}); | ||
const mapDispatchToProps = { | ||
updateNameField: updateNameField, | ||
createUser: createUser | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(UserCreator); | ||
export default connect(mapStateToProps, mapDispatchToProps)( | ||
reduxForm({ | ||
getFormState: state => { | ||
return state; | ||
}, | ||
form: "user" | ||
})(UserCreator) | ||
); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2101,6 +2101,10 @@ es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14: | |
es6-iterator "2" | ||
es6-symbol "~3.1" | ||
|
||
es6-error@^4.0.0: | ||
version "4.0.2" | ||
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.0.2.tgz#eec5c726eacef51b7f6b73c20db6e1b13b069c98" | ||
|
||
es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.1: | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.1.tgz#8e319c9f0453bf575d374940a655920e59ca5512" | ||
|
@@ -3889,7 +3893,7 @@ locate-path@^2.0.0: | |
p-locate "^2.0.0" | ||
path-exists "^3.0.0" | ||
|
||
lodash-es@^4.2.0, lodash-es@^4.2.1: | ||
lodash-es@^4.17.3, lodash-es@^4.2.0, lodash-es@^4.2.1: | ||
version "4.17.4" | ||
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.4.tgz#dcc1d7552e150a0640073ba9cb31d70f032950e7" | ||
|
||
|
@@ -4987,7 +4991,7 @@ [email protected], promise@^7.1.1: | |
dependencies: | ||
asap "~2.0.3" | ||
|
||
prop-types@^15.5.0, prop-types@^15.5.10: | ||
prop-types@^15.5.0, prop-types@^15.5.10, prop-types@^15.5.9: | ||
version "15.5.10" | ||
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154" | ||
dependencies: | ||
|
@@ -5266,6 +5270,19 @@ reduce-function-call@^1.0.1: | |
dependencies: | ||
balanced-match "^0.4.2" | ||
|
||
redux-form@^7.0.3: | ||
version "7.0.3" | ||
resolved "https://registry.yarnpkg.com/redux-form/-/redux-form-7.0.3.tgz#80157d01df7de6c8eb2297ad1fbbb092bafa34f5" | ||
dependencies: | ||
deep-equal "^1.0.1" | ||
es6-error "^4.0.0" | ||
hoist-non-react-statics "^2.2.1" | ||
invariant "^2.2.2" | ||
is-promise "^2.1.0" | ||
lodash "^4.17.3" | ||
lodash-es "^4.17.3" | ||
prop-types "^15.5.9" | ||
|
||
redux-loop@^3.1.2: | ||
version "3.1.2" | ||
resolved "https://registry.yarnpkg.com/redux-loop/-/redux-loop-3.1.2.tgz#5abbae1bb96ecaff1a51dcbb8b8978c6166b1522" | ||
|