parsec-hooks 0.0.156 → 0.0.160
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.
@@ -28,18 +28,13 @@ function _default(depState) {
|
|
28
28
|
state = _useState2[0],
|
29
29
|
setState = _useState2[1];
|
30
30
|
|
31
|
-
var
|
31
|
+
var timeRef = (0, _react.useRef)(+new Date());
|
32
32
|
(0, _debounceEffectHooks.default)(function () {
|
33
|
-
if (
|
33
|
+
if (+new Date() - timeRef.current > 10) {
|
34
34
|
setState(depState);
|
35
|
-
} else {
|
36
|
-
effectRef.current = false;
|
37
35
|
}
|
38
36
|
}, [depState], (0, _objectSpread2.default)({
|
39
37
|
wait: wait
|
40
38
|
}, other));
|
41
|
-
return [state,
|
42
|
-
setState(state);
|
43
|
-
effectRef.current = false;
|
44
|
-
}, [])];
|
39
|
+
return [state, setState];
|
45
40
|
}
|
@@ -28,7 +28,7 @@ export default function <D>(getListFn: LoadMoreGetListFn<D>, { defaultLimit, def
|
|
28
28
|
};
|
29
29
|
loading: boolean;
|
30
30
|
refreshList: (retainList?: boolean) => Promise<void>;
|
31
|
-
getNext: () =>
|
31
|
+
getNext: (callback?: () => void) => void;
|
32
32
|
isEnd: boolean;
|
33
33
|
page: number;
|
34
34
|
limit: number;
|
@@ -114,27 +114,30 @@ function _default(getListFn, _ref) {
|
|
114
114
|
|
115
115
|
|
116
116
|
var refreshList = (0, _react.useCallback)(function (retainList) {
|
117
|
+
if (!needGet) {
|
118
|
+
return;
|
119
|
+
}
|
120
|
+
|
117
121
|
if (!retainList) {
|
118
122
|
setData(initData);
|
119
123
|
}
|
120
124
|
|
121
125
|
return handleGetList(retainList);
|
122
|
-
}, [handleGetList, initData, setData]);
|
126
|
+
}, [handleGetList, initData, needGet, setData]);
|
123
127
|
var visibleRef = (0, _stateRefHooks.default)(loadMoreVisible);
|
124
|
-
var
|
125
|
-
|
126
|
-
|
128
|
+
var isEndRef = (0, _stateRefHooks.default)(isEnd);
|
129
|
+
var getNext = (0, _react.useCallback)(function (callback) {
|
130
|
+
if (!isEndRef.current && !loadingRef.current && needGet) {
|
131
|
+
handleGetList().then(callback);
|
127
132
|
}
|
128
|
-
|
129
|
-
return Promise.resolve();
|
130
|
-
}, [handleGetList, isEnd, loadingRef, needGet]);
|
133
|
+
}, [handleGetList, isEndRef, loadingRef, needGet]);
|
131
134
|
(0, _react.useEffect)(function () {
|
132
135
|
if (needGet) {
|
133
136
|
// 当handleGetList发生变化清空数据
|
134
137
|
refreshList().then(function () {
|
135
138
|
var fn = function fn() {
|
136
139
|
if (visibleRef.current) {
|
137
|
-
getNext(
|
140
|
+
getNext(fn);
|
138
141
|
}
|
139
142
|
};
|
140
143
|
|
@@ -11,7 +11,7 @@ declare const _default: <D extends unknown>(getList: LoadMoreGetListFn<D>, optio
|
|
11
11
|
};
|
12
12
|
loading: boolean;
|
13
13
|
refreshList: (retainList?: boolean) => Promise<void>;
|
14
|
-
getNext: () =>
|
14
|
+
getNext: (callback?: () => void) => void;
|
15
15
|
isEnd: boolean;
|
16
16
|
page: number;
|
17
17
|
limit: number;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "parsec-hooks",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.160",
|
4
4
|
"description": "秒差距前端常用的hooks工具",
|
5
5
|
"author": "mushan0x0",
|
6
6
|
"license": "MIT",
|
@@ -36,28 +36,28 @@
|
|
36
36
|
"@babel/runtime": "^7.10.3",
|
37
37
|
"classnames": "^2.2.6",
|
38
38
|
"crypto-js": "^4.0.0",
|
39
|
-
"dayjs": "^1.8.21",
|
40
39
|
"import-cdn-js": "^0.0.2",
|
41
40
|
"intersection-observer": "^0.8.0",
|
42
41
|
"qs": "^6.9.4",
|
43
|
-
"rc-field-form": "^1.2.0",
|
44
|
-
"remax": "^2.11.4",
|
45
42
|
"resize-observer-polyfill": "^1.5.1",
|
46
43
|
"unstated-next": "^1.1.0"
|
47
44
|
},
|
48
45
|
"peerDependencies": {
|
46
|
+
"dayjs": "^1.8.0",
|
49
47
|
"prop-types": "^15.5.4",
|
48
|
+
"rc-field-form": "^1.2.0",
|
50
49
|
"react": "^15.0.0 || ^16.0.0",
|
51
50
|
"react-dom": "^15.0.0 || ^16.0.0",
|
52
|
-
"remax": "^2.
|
51
|
+
"remax": "^2.0.0"
|
53
52
|
},
|
54
53
|
"devDependencies": {
|
55
54
|
"@babel/helper-call-delegate": "^7.10.3",
|
56
55
|
"@babel/plugin-syntax-typescript": "^7.10.4",
|
57
56
|
"@types/qs": "^6.9.3",
|
58
|
-
"@types/react": "^
|
57
|
+
"@types/react": "^17.0.38",
|
59
58
|
"@types/react-dom": "^16.0.5",
|
60
59
|
"@types/vfile-message": "^2.0.0",
|
60
|
+
"dayjs": "^1.8.21",
|
61
61
|
"dumi": "^1.0.34",
|
62
62
|
"eslint": "^6.8.0",
|
63
63
|
"eslint-config-prettier": "^6.10.0",
|
@@ -75,8 +75,10 @@
|
|
75
75
|
"np": "^6.2.4",
|
76
76
|
"prettier": "^1.19.1",
|
77
77
|
"pretty-quick": "^2.0.1",
|
78
|
+
"rc-field-form": "^1.2.0",
|
78
79
|
"react": "^16.4.1",
|
79
80
|
"react-dom": "^16.4.1",
|
81
|
+
"remax": "^2.11.4",
|
80
82
|
"typescript": "^3.9.5"
|
81
83
|
},
|
82
84
|
"files": [
|