I am fetching data from my firebase database in componentDidMount method.
componentDidMount = () => {
firebase.database().ref('posts').on('value', (snapshot) => {
this.setState({
posts: snapshot.val()
})
})
}
I want use this data in my render method. The problem is - when the render method executes, my state is not updated yet, because its async and the state is null. How can I render my data after state changes and i will have my data in my state ?