Skip to content

Instantly share code, notes, and snippets.

@luisrudge
Created January 30, 2020 22:24

Revisions

  1. luisrudge created this gist Jan 30, 2020.
    16 changes: 16 additions & 0 deletions file.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    const TheComponent = () => {
    const [error, setError] = React.useState();

    React.useEffect(() => {
    const asyncOperation = async () => {
    // do something async
    };

    asyncOperation().catch(e => {
    setError(() => {
    throw e;
    });
    });

    }, []);
    };