title: How to use 'useErrorHandler()' in React?
body: <p>I am looking at the <code>react-error-boundary</code> library from <a href="https://www.npmjs.com/package/react-error-boundary#useerrorhandlererror-error" rel="nofollow noreferrer">here</a> but I do not understand how to use the <code>useErrorHandler(error?: Error)</code>prop.</p>
  <p>So lets say I wrap my app with the error boundary - something like this</p>
  <pre><code>import {ErrorBoundary} from 'react-error-boundary';
  
  &lt;ErrorBoundary onError={myErrorHandler}&gt;
    &lt;App /&gt;
  &lt;/ErrorBoundary&gt;
  </code></pre>
  <p>How do I use 'useErrorHandler' to catch errors in the asynchronous code callbacks for example to propagate to <code>ErrorBoundary</code> so I can then use <code>myErrorHandler</code>?</p>
  <p>Where is 'useErrorHandler' defined or imported?</p>
  <p>I am trying to use this as a catch all error setup - sort of when you add throws excection to the main in java.</p>
  <p>async code example:</p>
  <pre><code>  ...
    return new Promise(function (resolve, reject) {
        axios({
          ...
        })
          .then((res) =&gt; {
            resolve(res);
            // &lt;-- ?
          })
          .catch((err) =&gt; {
            reject(err);
          });
      });
  </code></pre>