File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -44,27 +44,30 @@ Two things needs to be done to use **react-input-handler**:
4444import React from ' react'
4545import ReactInputHandler from ' react-input-handler'
4646
47- class Form extends React .Component {
47+ export default class Form extends React .Component {
4848
4949 constructor (props ) {
5050 super (props)
51+
52+ this .state = {}
53+
5154 this .handleChange = ReactInputHandler .bind (this )
52- this .handleSubmit .bind (this )
55+ this .handleSubmit = this . handleSubmit .bind (this )
5356 }
5457
5558 render () {
5659 return (
57- < form>
60+ < form onSubmit = { this . handleSubmit } >
5861 < label> Fullname: < / label>
5962 < input type= " text" name= " user.fullname" onChange= {this .handleChange } / >
60-
63+
6164 < label> Biography: < / label>
62- < textarea type= " text" name= " user.bio" onChange= {this .inputHandler } / >
63-
65+ < textarea type= " text" name= " user.bio" onChange= {this .handleChange } / >
66+
6467 < label> Are you a developer? < / label>
65- < input type= " checkbox" name= " user.developer" value= " yes" onChange= {this .inputHandler } / >
66-
67- < button onClick = { this . handleSubmit } > Submit< / button>
68+ < input type= " checkbox" name= " user.developer" value= " yes" onChange= {this .handleChange } / >
69+
70+ < button type = " submit " > Submit< / button>
6871 < / form>
6972 )
7073 }
@@ -74,7 +77,6 @@ class Form extends React.Component {
7477 console .log (this .state )
7578 // Output: { user: { fullanme: "string", bio: "string", developer: true|false } }
7679 }
77-
7880}
7981` ` `
8082
You can’t perform that action at this time.
0 commit comments