Skip to content

Instantly share code, notes, and snippets.

@ccapndave
Created June 17, 2020 20:09
Show Gist options
  • Save ccapndave/72448a7db263178fc2b0f5bb93e715c1 to your computer and use it in GitHub Desktop.
Save ccapndave/72448a7db263178fc2b0f5bb93e715c1 to your computer and use it in GitHub Desktop.
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