Skip to content

Instantly share code, notes, and snippets.

@koba04
Created March 27, 2015 00:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koba04/d042d3fc709bbe6c7556 to your computer and use it in GitHub Desktop.
Save koba04/d042d3fc709bbe6c7556 to your computer and use it in GitHub Desktop.
class Sample extends React.Component {
getInitialState() {
return { data: this.props.initialData };
}
componentDidMount() {
if (!this.props.initialDada) {
request('/api/xxx')
.end((err, res) => {
this.setState({ data: res.body });
})
}
}
render() {
return <div>{this.state.data}</div>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment