componentDidMount() {
Store.fetchData();
}
Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
Store.fetchData().then( ... )
Store.on('DATA_LOADED', (data) => this.setState({ data }); //как пример
class SomeComponent {
...
componentDidMount() {
Store.addListener("DATA_CHANGED", this.handleChanged)
Store.addListener("DATA_LOADED", this.handleLoaded)
}
...
handleLoaded(){
// just force rendering (you can do something smart beforehand though)
this.forceUpdate()
}
...
renderContent(){
// your usual render code
...
}
renderLoading(){
return <Icon type="spinner" spin />
}
render(){
if(Store.isLoading()){
return this.renderLoading()
} else {
return this.renderContent()
}
}
}