class CardComponent extends Component {
componentDidMount() {
const self = this;
api.getData(data => self.setState({ articleData: data }));
}
render() {
return (
<div>
<h1>{'This will always render'}</h1>
{ this.state && this.state.articleData &&
<div>{'This will render after the return of the async call'}</div>
}
</div>
)
}
}
CardComponent
The CardComponent renders a simple h1 with a message that will always be rendered, and a div with the rendered data after the return of the async call.
Shortcut: react.CardComponent
0 Comments
Add Comment
Log in to add a comment