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>
);
}```
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>
);
}