Cannot read properties of undefined (reading 'every')
What you were expecting:
I am using useUpdateMany to update a set of records, expected
What happened instead:
Once complete it throws
Cannot read properties of undefined (reading 'every')
Steps to reproduce:
Related code:
const [update, { loading: saving }] = useUpdateMany(
props.resource,
props.selectedIds,
undefined, // set by the caller
{
onSuccess: () => {
unselectAll(props.resource);
setDialogOpen(false);
notify(`Allocated ${props.selectedIds?.length} successfully`);
refresh();
},
onFailure: (error) => {
console.error(error);
notify("An Error Occurred");
},
}
);
Other information:
I have attempted to debug my data providers but cannot see anything related to this, it looks like occurs before the data provider is called and attempts to call getMany within replyWithCache.ts
Environment
- React-admin version: 3.19.6
- Last version that did not exhibit the issue (if applicable): 3.18.2
- React version: 17.0.2
- Browser: Chrome
- Stack trace (in case of a JS error):
After more testing, I found that it is the refresh(); call that is causing this issue and not the updateMany itself
Can you please provide a reproduction based on the simple example codesandbox?
https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple
@fzaninotto turns out this was caused by another useQuery with action getMany much further up the chain, I am not sure why using refresh would make react-admin try refresh that specific query however instead of the list the bulk action was tied to
I am going to close this issue as my issue is solved