Skip to content

Instantly share code, notes, and snippets.

@getaclue00
Created November 15, 2018 23:29
Show Gist options
  • Select an option

  • Save getaclue00/0ad89262a04f727998ebd346e57e34fe to your computer and use it in GitHub Desktop.

Select an option

Save getaclue00/0ad89262a04f727998ebd346e57e34fe to your computer and use it in GitHub Desktop.
Stateful vs. Stateless
// https://stackoverflow.com/a/49920844
// Stateless
const ProjectListComponent = (props) => {
const { handleClick } = props
return (
<button onClick={handleClick}>Click me</button>
)
}
class AppComponent extends Component {
handleClick() {
console.log('clicked')
}
render() {
return (
<ProjectListComponent onClick={this.handleClick} />
)
}
}
// Stateful
class ProjectListComponent extends Component {
handleClick() {
console.log('clicked')
}
render() {
return (
<button onClick={this.handleClick}>Click me</button>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment