@zykj2024/much-library 1.1.5-beta.3 → 1.1.5
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.
@@ -1,5 +1,5 @@
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
-
import React, { useEffect, useRef, useState } from 'react';
|
2
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
4
4
|
var getKey = function getKey(child, index) {
|
5
5
|
var _child$key;
|
@@ -27,10 +27,12 @@ var ObserverInsertionWrapper = function ObserverInsertionWrapper(_ref) {
|
|
27
27
|
setVisibleItems = _useState2[1];
|
28
28
|
|
29
29
|
// 为避免 children 每次渲染变化导致 useEffect 重复执行,构建一个 keyList 哈希
|
30
|
-
var
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
var keyListHash = useMemo(function () {
|
31
|
+
var list = React.Children.toArray(children).map(function (child, index) {
|
32
|
+
return getKey(child, index);
|
33
|
+
});
|
34
|
+
return JSON.stringify(list);
|
35
|
+
}, [children]);
|
34
36
|
|
35
37
|
// 每次 keyList 变动重置显示列表
|
36
38
|
useEffect(function () {
|
@@ -65,7 +67,7 @@ var ObserverInsertionWrapper = function ObserverInsertionWrapper(_ref) {
|
|
65
67
|
observer.unobserve(element);
|
66
68
|
});
|
67
69
|
};
|
68
|
-
}, [offset, threshold, root, keyListHash
|
70
|
+
}, [offset, threshold, root, keyListHash]);
|
69
71
|
return /*#__PURE__*/_jsx("div", {
|
70
72
|
ref: wrapperRef,
|
71
73
|
style: style,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zykj2024/much-library",
|
3
|
-
"version": "1.1.5
|
3
|
+
"version": "1.1.5",
|
4
4
|
"description": "react library",
|
5
5
|
"license": "MIT",
|
6
6
|
"module": "dist/index.js",
|
@@ -22,7 +22,6 @@
|
|
22
22
|
"lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
|
23
23
|
"prepare": "husky install && dumi setup",
|
24
24
|
"prepublishOnly": "father doctor && npm run build",
|
25
|
-
"publish": "npm publish",
|
26
25
|
"publish-dev": "npm publish --tag beta",
|
27
26
|
"start": "npm run dev"
|
28
27
|
},
|