• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

react-ui-org / react-ui / 14771731404

01 May 2025 07:27AM CUT coverage: 90.283%. First build
14771731404

Pull #631

github

web-flow
Merge ae3f2b3b0 into 00d28976a
Pull Request #631: Allow to reset `FileInputField` internal state by calling `resetState` function on its ref (#630)

807 of 897 branches covered (89.97%)

Branch coverage included in aggregate %.

6 of 9 new or added lines in 1 file covered. (66.67%)

754 of 832 relevant lines covered (90.63%)

73.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

37.93
/src/components/ScrollView/_hooks/useLoadResizeHook.js
1
import {
2
  useLayoutEffect,
3
  useRef,
4
} from 'react';
5
import { getElementsPositionDifference } from '../_helpers/getElementsPositionDifference';
6

7
export const useLoadResize = (effect, dependencies, contentEl, viewportEl, wait) => {
8✔
8
  const throttleTimeout = useRef(null);
30✔
9

10
  const callBack = (wasDelayed = false) => {
30!
11
    effect(getElementsPositionDifference(contentEl, viewportEl));
×
12

13
    if (wasDelayed) {
×
14
      throttleTimeout.current = null;
×
15
    }
16
  };
17

18
  useLayoutEffect(() => {
30✔
19
    const handleLoadResize = () => {
30✔
20
      if (wait) {
×
21
        if (throttleTimeout.current === null) {
×
22
          throttleTimeout.current = setTimeout(callBack, wait, true);
×
23
        }
24
      } else {
25
        callBack();
×
26
      }
27
    };
28

29
    window.addEventListener('load', handleLoadResize);
30✔
30
    window.addEventListener('resize', handleLoadResize);
30✔
31

32
    return () => {
30✔
33
      clearTimeout(throttleTimeout.current);
30✔
34
      window.removeEventListener('load', handleLoadResize);
30✔
35
      window.removeEventListener('resize', handleLoadResize);
30✔
36
    };
37
  }, dependencies); // eslint-disable-line react-hooks/exhaustive-deps
38
};
39

40
export default useLoadResize;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc