aboutsummaryrefslogtreecommitdiff
path: root/modern/src/reactHelper.js
blob: cd161d464df394524cabe48c1d208b6a90c91afe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { useRef, useEffect } from 'react';

export const usePrevious = value => {
  const ref = useRef();
  useEffect(() => {
    ref.current = value;
  });
  return ref.current;
}

export const useEffectAsync = (effect, deps) => {
  useEffect(() => {
    effect();
  }, [effect, ...deps]); // eslint-disable-line react-hooks/exhaustive-deps
}