Created
June 17, 2020 20:09
-
-
Save ccapndave/72448a7db263178fc2b0f5bb93e715c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var useFetch = function (request) { | |
var match = React.useState(function () { | |
return /* Loading */ 0; | |
}); | |
var setState = match[1]; | |
React.useEffect( | |
function () { | |
fetchAndDecode(request).then(function (result) { | |
return Promise.resolve( | |
Curry._1(setState, function (param) { | |
return /* Complete */ [result]; | |
}) | |
); | |
}); | |
}, | |
[request] | |
); | |
return match[0]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment