Why can't I directly modify a component's state, really?

前端 未结 7 936
感动是毒
感动是毒 2020-11-21 22:40

I understand that React tutorials and documentation warn in no uncertain terms that state should not be directly mutated and that everything should go through setState

7条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-21 23:21

    setState trigger re rendering of the components.when we want to update state again and again we must need to setState otherwise it doesn't work correctly.

提交回复
热议问题