aboutsummaryrefslogtreecommitdiff
path: root/modern/src/reactHelper.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/reactHelper.js')
-rw-r--r--modern/src/reactHelper.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/modern/src/reactHelper.js b/modern/src/reactHelper.js
index f3ef78dd..7503360a 100644
--- a/modern/src/reactHelper.js
+++ b/modern/src/reactHelper.js
@@ -9,7 +9,14 @@ export const usePrevious = (value) => {
};
export const useEffectAsync = (effect, deps) => {
+ const ref = useRef();
useEffect(() => {
- effect();
+ effect().then((result) => ref.current = result);
+ return () => {
+ const result = ref.current;
+ if (result) {
+ result();
+ }
+ };
}, deps);
};