Skip to content

Instantly share code, notes, and snippets.

@raidenz
Last active August 18, 2018 07:06
Show Gist options
  • Save raidenz/e6b597b85e9c2c78003701a04b012301 to your computer and use it in GitHub Desktop.
Save raidenz/e6b597b85e9c2c78003701a04b012301 to your computer and use it in GitHub Desktop.
:medium: smart component
import React from 'react'
class Statefull extends React.Component {
constructor(props){
super(props)
this.state={
name: ''
}
}
handleChange = (e) => {
const {name, value} = e.target
this.setState({
name: value
})
}
render(){
return(
<div>
Statefull Component
<div>
name: {this.state.name}
</div>
<input name="name" value={this.state.name} onChange={this.handleChange}/>
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment