Skip to content

Instantly share code, notes, and snippets.

@wwwhatley
Created June 28, 2018 15:27
Show Gist options
  • Save wwwhatley/a02d2ed674fd97573580c549ef390e25 to your computer and use it in GitHub Desktop.
Save wwwhatley/a02d2ed674fd97573580c549ef390e25 to your computer and use it in GitHub Desktop.
Example
class Greeting extends React.Component {
constructor() {
super();
this.state = {
name: "",
};
}
componentDidMount() {
// AJAX
this.setState(() => {
return {
name: "William",
};
});
}
render() {
return (
<div>
<h1>Hello! {this.state.name}</h1>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment