Created
July 17, 2018 20:10
-
-
Save kocisov/ba8d62ce1d4b1949b442bb4bd601426b to your computer and use it in GitHub Desktop.
Sup
This file contains hidden or 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
import * as React from 'react' | |
class Button extends React.PureComponent { | |
render() { | |
return ( | |
<button onClick={this.props.onClick}>{this.props.text}</button> | |
} | |
} | |
} | |
export default class extends React.PureComponent { | |
state = { | |
value: '' | |
} | |
onChange = (event) => { | |
this.setState({ | |
[event.target.name]: event.target.value | |
}) | |
} | |
handleClick = () => { | |
console.log(this.state.value) | |
} | |
render() { | |
return [ | |
<input | |
key="0" | |
name="value" | |
type="text" | |
value={this.state.value} | |
onChange={this.handleChange} | |
/>, | |
<Button onClick={this.handleClick} text="Submit" /> | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment