setState doesn't update the state immediately

前端 未结 12 2481
暖寄归人
暖寄归人 2020-11-21 05:25

I would like to ask why my state is not changing when I do an onclick event. I\'ve search a while ago that I need to bind the onclick function in constructor but still the s

12条回答
  •  北海茫月
    2020-11-21 05:45

    when i was running the code and checking my output at console it showing the that it is undefined. After i search around and find something that worked for me.

    componentDidUpdate(){}
    

    I added this method in my code after constructor(). check out the life cycle of react native workflow.

    https://images.app.goo.gl/BVRAi4ea2P4LchqJ8

提交回复
热议问题