-
-
Save tristanpendergrass/1427484e5f496c7ab304d78d08a86e11 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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