Why you need the isMounted
state? If you are using this state just to be a condition to set the state posts
, you could just call the getPosts
method inside the componentDidMount
function and should work as you expected:
async componentDidMount(){
await getPosts()
}
You got it?
Waiting for your feedback about my answer. Thx :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…