I have a async function in a custom hook which should update the state but it doesn't
export const useXYZ = () => {
const [XYZ, setXYZ] = useState([])
const update = () => {
BackendService.getAllXYZ().then(
({data}) => {
//------------>>> here I want to update, but if I use the hook it doesnt update if I call update()
setXYZ(data)
}
).catch((error)=>{
})
}
return [XYZ, update]
}