老师,App.js中的fileSearch
在收到onFileSearch
的调用时,调用了很多次,每次试验时的次数还有一些变化。
分析原因是感觉是useKeyPress这里有些问题,当keyDownHandler
被调用时setKeyPress(true);
,如果一直按着不松手,那么就会
Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.
in FileSearch (at App.js:86)
in div (at App.js:85)
in div (at App.js:84)
in div (at App.js:83)
in App (at src/index.js:7)
不确定fileSearch
被多次调用是不是由于按键时间长短这个原因造成的?