Skip to content

Instantly share code, notes, and snippets.

@tristanpendergrass
Created February 16, 2018 18:26
Show Gist options
  • Save tristanpendergrass/1427484e5f496c7ab304d78d08a86e11 to your computer and use it in GitHub Desktop.
Save tristanpendergrass/1427484e5f496c7ab304d78d08a86e11 to your computer and use it in GitHub Desktop.
class Parent extends Component {
state = {
data: null,
};
componentWillMount() {
loadData().then(data => {
this.setState({ data });
});
}
render() {
const { data } = this.state;
return (
<Fragment>
{!data &&
<div>Loading...</div>
}
{data &&
<Grapes data={data} />
}
</Fragment>
);
}
}
class Grapes extends Component {
componentWillMount() {
// do grapes stuff that can only happen after you have the data
}
render() {
// this will also only happen after you already have the data
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment