useLayoutEffect.js 479 B

1234567891011121314151617
  1. /* eslint-disable react-hooks/rules-of-hooks */
  2. import * as React from 'react';
  3. import { isBrowserClient } from "../utils/commonUtil";
  4. /**
  5. * Wrap `React.useLayoutEffect` which will not throw warning message in test env
  6. */
  7. export default function useLayoutEffect(effect, deps) {
  8. // Never happen in test env
  9. if (isBrowserClient) {
  10. /* istanbul ignore next */
  11. React.useLayoutEffect(effect, deps);
  12. } else {
  13. React.useEffect(effect, deps);
  14. }
  15. }
  16. /* eslint-enable */