How to fix missing dependency warning when using useEffect React Hook?

前端 未结 13 1801
无人及你
无人及你 2020-11-22 03:14

With React 16.8.6 (it was good on previous version 16.8.3), I get this error when I attempt to prevent an infinite loop on a fetch request

./src/components/Bu         


        
13条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 03:24

    Just pass the function as the argument in the array of useEffect...

    useEffect(() => {
       functionName()
    }, [functionName])
    

提交回复
热议问题