Skip to content

Instantly share code, notes, and snippets.

@eiriklv
Last active November 27, 2015 13:50
Show Gist options
  • Save eiriklv/35100a63009d3b61b655 to your computer and use it in GitHub Desktop.
Save eiriklv/35100a63009d3b61b655 to your computer and use it in GitHub Desktop.
Stating intent and using conventions
const React = require('react');
const MyComponent = React.createClass({
propTypes: {
},
getDefaultProps() {
},
getInitialState() {
},
componentWillMount() {
},
componentDidMount() {
},
componentWillReceiveProps() {
},
shouldComponentUpdate() {
},
componentDidUpdate() {
},
handleSomeThing() {
},
handleSomeThingElse() {
},
render() {
const {
error
isLoading,
data
} = this.props;
const {
showDetails
} = this.state;
if (error) {
return <div>Error: {error}</div>;
}
if (loading) {
return <div>loading..</div>;
}
return (
<div>
<p>Success {data.info}!</p>
{showDetails && <p>{data.details}</p>}
</div>
);
}
});
module.exports = MyComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment