source: imaps-frontend/node_modules/react-use/esm/usePromise.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 567 bytes
Line 
1import { useCallback } from 'react';
2import useMountedState from './useMountedState';
3var usePromise = function () {
4 var isMounted = useMountedState();
5 return useCallback(function (promise) {
6 return new Promise(function (resolve, reject) {
7 var onValue = function (value) {
8 isMounted() && resolve(value);
9 };
10 var onError = function (error) {
11 isMounted() && reject(error);
12 };
13 promise.then(onValue, onError);
14 });
15 }, []);
16};
17export default usePromise;
Note: See TracBrowser for help on using the repository browser.