lkd-web-kit 0.7.10 → 0.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,14 +20,31 @@ const InfinityLoader = ({
20
20
  rootMargin
21
21
  });
22
22
  React.useEffect(() => {
23
- if (entry?.isIntersecting && infinity.hasNextPage) infinity.fetchNextPage();
24
- }, [entry?.isIntersecting]);
23
+ if (!entry?.isIntersecting) return;
24
+ if (!infinity.hasNextPage) return;
25
+ if (infinity.isFetchingNextPage || infinity.isFetching) return;
26
+ infinity.fetchNextPage();
27
+ }, [
28
+ entry?.isIntersecting,
29
+ infinity.hasNextPage,
30
+ infinity.isFetchingNextPage,
31
+ infinity.isFetching
32
+ ]);
25
33
  React.useEffect(() => {
26
34
  if (!entry?.isIntersecting) return;
27
35
  const el = root?.current ?? document.documentElement;
28
36
  const hasScroll = el?.scrollHeight > el?.clientHeight;
29
- if (!hasScroll) infinity.fetchNextPage();
30
- }, [entry?.isIntersecting, infinity.data?.pages.length]);
37
+ if (hasScroll) return;
38
+ if (!infinity.hasNextPage) return;
39
+ if (infinity.isFetchingNextPage || infinity.isFetching) return;
40
+ infinity.fetchNextPage();
41
+ }, [
42
+ entry?.isIntersecting,
43
+ infinity.data?.pages.length,
44
+ infinity.hasNextPage,
45
+ infinity.isFetchingNextPage,
46
+ infinity.isFetching
47
+ ]);
31
48
  const showLoader = infinity.isLoading || infinity.isFetchingNextPage;
32
49
  const showEndMessage = infinity.data && infinity.data.pages.length > 1 && !infinity.hasNextPage;
33
50
  if (!showLoader && !showEndMessage) {
@@ -16,14 +16,31 @@ const InfinityLoader = ({
16
16
  rootMargin
17
17
  });
18
18
  useEffect(() => {
19
- if (entry?.isIntersecting && infinity.hasNextPage) infinity.fetchNextPage();
20
- }, [entry?.isIntersecting]);
19
+ if (!entry?.isIntersecting) return;
20
+ if (!infinity.hasNextPage) return;
21
+ if (infinity.isFetchingNextPage || infinity.isFetching) return;
22
+ infinity.fetchNextPage();
23
+ }, [
24
+ entry?.isIntersecting,
25
+ infinity.hasNextPage,
26
+ infinity.isFetchingNextPage,
27
+ infinity.isFetching
28
+ ]);
21
29
  useEffect(() => {
22
30
  if (!entry?.isIntersecting) return;
23
31
  const el = root?.current ?? document.documentElement;
24
32
  const hasScroll = el?.scrollHeight > el?.clientHeight;
25
- if (!hasScroll) infinity.fetchNextPage();
26
- }, [entry?.isIntersecting, infinity.data?.pages.length]);
33
+ if (hasScroll) return;
34
+ if (!infinity.hasNextPage) return;
35
+ if (infinity.isFetchingNextPage || infinity.isFetching) return;
36
+ infinity.fetchNextPage();
37
+ }, [
38
+ entry?.isIntersecting,
39
+ infinity.data?.pages.length,
40
+ infinity.hasNextPage,
41
+ infinity.isFetchingNextPage,
42
+ infinity.isFetching
43
+ ]);
27
44
  const showLoader = infinity.isLoading || infinity.isFetchingNextPage;
28
45
  const showEndMessage = infinity.data && infinity.data.pages.length > 1 && !infinity.hasNextPage;
29
46
  if (!showLoader && !showEndMessage) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkd-web-kit",
3
- "version": "0.7.10",
3
+ "version": "0.7.11",
4
4
  "description": "A template for creating React component libraries with Vite.",
5
5
  "author": "LKD",
6
6
  "license": "MIT",