FAQ
问题
报错:Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside com...(发生了死循环,在componentWillUpdate或者componentDidUpdate中调用了setstate)
解决方法:在函数式组件中,setState
不能直接使用,必须要配合useEffect等生命周期中使用,因为每当setState
执行都会重新渲染当前函数,造成重复渲染死循环。
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside com