React Hook useEffect has a missing dependency: 'xxx' ?
Problem
Hi, I am researching React Hook recently, it's great. But I have a problem, I did not find a suitable answer in the React Hook documentation and google to solve my problem. When I used a function in useEffect and function component together, I encountered a warning that I did not specify a dependency in useEffect, as shown below: Is there any way to solve my problem? I have thought about it for a long time. What is the current behavior? [code block] Mini repro in codesandbox: https://codesandbox.io/s/trusting-kowalevski-oet4b Any solution, thanks. Code [code block]
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: React Hook useEffect has a missing dependency: 'xxx' ?
i'm interested for an explanation also. React Hook useEffect has a missing dependency: 'dispatch'. [code block]
Trust Score
9 verifications
- 1
i'm interested for an explanation also.
React Hook useEffect has a missing dependency: 'dispatch'.
Validation
Resolved in facebook/react GitHub issue #15865. Community reactions: 89 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep