-
-
Save ryanswrt/3aaa353bb0fce285c479f71079478007 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const useCallThatCanFail = (query) => { | |
const [error, setError] = useState(); | |
const [result, setResult] = useState(); | |
useEffect(() => { | |
callbackThatCanFail(query) | |
.then((r) => { | |
setResult(r); | |
setError(undefined); | |
}).catch((e) => { | |
setError(e); | |
setResult(undefined); | |
} | |
) | |
}, [query]); | |
return [result, error]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment