@fringeworks/react-defer-rendering 0.8.0 → 0.8.1

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.
package/README.ja.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @fringeworks/react-defer-rendering
2
2
 
3
- `@fringeworks/react-defer-rendering` は、指定した条件が満たされるまでコンポーネントの描画を遅延させることに特化したニッチなライブラリです。\
3
+ `@fringeworks/react-defer-rendering` は、指定した条件が満たされるまでコンポーネントの描画を遅延させることに特化した、誰かにとっては便利なライブラリです。\
4
4
  タイマー、Promise、ブラウザAPI(`matchMedia`、`IntersectionObserver`等)など、様々な条件に対応したフック群を提供します。
5
5
 
6
6
  **[English README is available here](./README.md)**
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @fringeworks/react-defer-rendering
2
2
 
3
- `@fringeworks/react-defer-rendering` is a niche library specialized in deferring the rendering of components until a specified condition is met.\
3
+ `@fringeworks/react-defer-rendering` is a library some will find handy, specialized in deferring the rendering of components until a specified condition is met.\
4
4
  It provides a set of hooks covering a wide range of conditions, including timers, Promises, and browser APIs (`matchMedia`, `IntersectionObserver`, etc.).
5
5
 
6
6
  **[日本語のREADMEはこちら](./README.ja.md)**
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@fringeworks/react-defer-rendering",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
+ "description": "A library some will find handy, specialized in deferring the rendering of components until a specified condition is met.",
4
5
  "keywords": [
5
6
  "react",
6
7
  "layout",
@@ -80,9 +81,9 @@
80
81
  "module": "./index.mjs",
81
82
  "types": "./index.d.cts",
82
83
  "dependencies": {
83
- "@fringeworks/react-utils": "^0.8.0",
84
- "@fringeworks/utils": "^0.8.0",
85
- "@fringeworks/web-font-observer": "^0.8.0"
84
+ "@fringeworks/react-utils": "^0.8.1",
85
+ "@fringeworks/utils": "^0.9.2",
86
+ "@fringeworks/web-font-observer": "^0.8.1"
86
87
  },
87
88
  "peerDependencies": {
88
89
  "react": "^18.0.0 || ^19.0.0",
package/types.d.cts CHANGED
@@ -55,8 +55,9 @@ type DeferRenderingResult<N extends ReactNode> = {
55
55
  state: RenderingState;
56
56
  /**
57
57
  * 描画するノード
58
+ * 表示を遅らせている間は null、該当するノードを指定していない場合は undefined
58
59
  */
59
- node: N;
60
+ node: N | null | undefined;
60
61
  };
61
62
  /**
62
63
  * 現在の状態と状態変更用のハンドラーを返す戻り値
package/types.d.mts CHANGED
@@ -55,8 +55,9 @@ type DeferRenderingResult<N extends ReactNode> = {
55
55
  state: RenderingState;
56
56
  /**
57
57
  * 描画するノード
58
+ * 表示を遅らせている間は null、該当するノードを指定していない場合は undefined
58
59
  */
59
- node: N;
60
+ node: N | null | undefined;
60
61
  };
61
62
  /**
62
63
  * 現在の状態と状態変更用のハンドラーを返す戻り値
@@ -33,7 +33,7 @@ function useDeferUntilIntersected(target, elementRef, options = {}) {
33
33
  if (!element) return () => {};
34
34
  const observer = new IntersectionObserver((entries) => {
35
35
  const entry = entries[0];
36
- if (snapshotRef.current !== entry.isIntersecting) {
36
+ if (entry && snapshotRef.current !== entry.isIntersecting) {
37
37
  snapshotRef.current = entry.isIntersecting;
38
38
  onStoreChange();
39
39
  }
@@ -31,7 +31,7 @@ function useDeferUntilIntersected(target, elementRef, options = {}) {
31
31
  if (!element) return () => {};
32
32
  const observer = new IntersectionObserver((entries) => {
33
33
  const entry = entries[0];
34
- if (snapshotRef.current !== entry.isIntersecting) {
34
+ if (entry && snapshotRef.current !== entry.isIntersecting) {
35
35
  snapshotRef.current = entry.isIntersecting;
36
36
  onStoreChange();
37
37
  }