Select theme appearance

UseThrowAsyncError

Hook to allow ErrorBoundary to work

  • Tags:  Typescript, React
  • Last updated:  

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