Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
State in React Hook useEffect has a missing dependency

How can I remove warnings like this error src\components\pages\badge\BadgeScreen.tsx Line 87:6: React Hook useEffect has a missing dependency: 'loadData'. Either include it or remove the dependency array react-hooks/exhaustive-deps

Here is my code:

const location = useLocation();
  const { badge }: any = location.state;

    const [data, setData] = useState({
        id: "",
        badge_name: "",
        badge_description: "",
        imgBase64: "",
        img_icon: "",
      });
    
            useEffect(() => {
            setData(badge);
          }, [badge]);

Everything is working fine, but I am having a hard time fixing this issue.

Thank you!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think you don't need useEffect because you can setData after location.state destructuring.

For example:

const location = useLocation();
const { badge }: any = location.state;
const [data, setData] = useState(badge);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!