我在componentDidMount中写了一个setState,来更新界面。
在没写shouldComponentUpdate的情况下,发现componentDidUpdate里面的代码被重复执行,但是写了shouldComponentUpdate之后,即便shouldComponentUpdate里返回false的情况根本就没有运行到,但是componentDidUpdate真的就执行一次了。
我感觉很奇怪,想问问各位,这到底是为什么啊?
难道在有setState的时候,必须写shouldComponentUpdate吗?