React
- 2 ответа
- 0 вопросов
3
Вклад в тег
componentDidMount() {
this.refresher = setInterval(1000, () => this.forceUpdate())
}
componentWillUnmount() {
clearInterval(this.refresher)
}
getInitialState() {
return {readyToRenderMap: false}
}
// DOM become available after component is mounted
// map can be displayed safely since componentDidMount does not get called in server environment
componentDidMount() {
this.setState({readyToRenderMap: true})
}
render() {
return <div>
<h1>Данные на карте:</h1>
{this.state.readyToRenderMap &&
<Map center={[55.754734, 37.583314]} zoom={10}>
<Marker lat={@props.lat} lon={@props.lon} />
</Map>
}
{!this.state.readyToRenderMap &&
Loading... (or some spinner component. whatever.)
}
<p>Немного поясняющего текста</p>
</div>
}