import { useNotify, useRedirect, List } from 'react-admin'; const PostList = () => { const notify = useNotify(); const redirect = useRedirect(); const onError = (error) => { notify(`Could not load list: ${error.message}`, { type: 'error' }); redirect('/dashboard'); }; return ( <List queryOptions={{ onError }}> ... </List> ); }
useRedirect进行重定向的操作