React Hook useEffect has a missing dependency: 'list'

前端 未结 5 2145
一个人的身影
一个人的身影 2021-01-04 20:27

Once I run the below code, I get the following error:

React Hook useEffect has a missing dependency: \'list\'. Either include it or remove the depende

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-04 20:52

    Inside your useEffect you are logging list:

    console.log(list);
    

    So you either need to remove the above line, or add list to the useEffect dependencies at the end. so change this line

    }, [term]);
    

    to

    }, [term, list]);
    

提交回复
热议问题