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

109
Views
React Hook "useDispatch" is called in function "setApprovedDecision" which is neither a React function component

Below is the code block through which i am getting error mentioned in title. Do we need to pass down the dispatch to child components. (All my child components are functional components)

import { useDispatch } from "react-redux";

export function ApproveModal(props) {
  const setApprovedDecision = () => {
    useDispatch({ type: SUBMIT_DECISION , payload: props.decisionData});
  };
  return (
    <Button buttonStyle="secondary" onClick={setApprovedDecision}>
    Approve
    </Button>
  );
}```
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you call useDispatch to return dispatch function, which then will be used to dispatch actions

import { useDispatch } from "react-redux";

export function ApproveModal(props) {
  const dispatch = useDipatch();
  const setApprovedDecision = () => {
    dispatch({ type: SUBMIT_DECISION , payload: props.decisionData});
  };
  return (
    <Button buttonStyle="secondary" onClick={setApprovedDecision}>
    Approve
    </Button>
  );
} 
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!