Created
March 27, 2015 00:51
-
-
Save koba04/d042d3fc709bbe6c7556 to your computer and use it in GitHub Desktop.
This file contains 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
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