UseThrowAsyncError
Hook to allow ErrorBoundary to work
Catching async errors with React’s ErrorBoundary.
const useThrowAsyncError = () => {
const [state, setState] = useState();
return (error) => {
setState(() => throw error)
}
}
Credits and explanation: https://www.developerway.com/posts/how-to-handle-errors-in-react