this.state = {
beerImage: null,
}
componentDidMount() {
promise.then(beer => this.setState({beerImage: beer.image}))
}
const {beerImage} = this.state;
<img src={beerImage} />
You may call setState() immediately in componentDidMount(). It will trigger an extra rendering, but it will happen before the browser updates the screen. This guarantees that even though the render() will be called twice in this case, the user won’t see the intermediate state.