I have a class component with the method below:
callBackCatAndSubcat = (values, type) => {
if (type === 'jobs') {
this.setState({ jobsSelected: values }, () => (
this.props.setFieldValue('jobsSelected', _.map(this.state.jobsSelected, (item) => item.id))
));
}
};
and i'm converting this component into a functional component to use hooks... i'm trying to convert this method, but it isn't working
Current code:
const [jobsSelected, setJobsSelected] = useState([]);
const callBackCatAndSubcat = useCallback((items, type) => {
if (type === 'jobs') {
setFieldValue('jobsSelected', items.map((item) => item.id));
}
}, [setFieldValue]);
I'm not receiving an error, but the function isn't working correctly