@etsoo/react 1.4.31 → 1.4.32

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.
@@ -36,7 +36,7 @@ export const ScrollerGrid = (props) => {
36
36
  // Update state
37
37
  state.isNextPageLoading = true;
38
38
  // Parameters
39
- const { currentPage, batchSize, orderBy, orderByAsc, data, isMounted } = state;
39
+ const { currentPage, batchSize, orderBy, orderByAsc, data } = state;
40
40
  const loadProps = {
41
41
  currentPage,
42
42
  batchSize,
@@ -45,10 +45,10 @@ export const ScrollerGrid = (props) => {
45
45
  data
46
46
  };
47
47
  loadData(loadProps).then((result) => {
48
- state.isMounted = true;
49
- if (result == null || isMounted === false) {
48
+ if (result == null || state.isMounted === false) {
50
49
  return;
51
50
  }
51
+ state.isMounted = true;
52
52
  const newItems = result.length;
53
53
  state.lastLoadedItems = newItems;
54
54
  state.isNextPageLoading = false;
@@ -109,7 +109,8 @@ export const ScrollerGrid = (props) => {
109
109
  };
110
110
  Object.assign(state, resetState);
111
111
  // Reset items
112
- setRows([]);
112
+ if (state.isMounted !== false)
113
+ setRows([]);
113
114
  };
114
115
  React.useImperativeHandle(mRef, () => ({
115
116
  scrollTo(params) {
@@ -184,13 +185,12 @@ export const ScrollerGrid = (props) => {
184
185
  shouldForceUpdate: true
185
186
  });
186
187
  }, [width]);
187
- // Destruct state
188
- const { autoLoad: stateAutoLoad, hasNextPage, currentPage } = state;
188
+ // Rows
189
189
  const rowLength = rows.length;
190
190
  // Row count
191
- const rowCount = hasNextPage ? rowLength + 1 : rowLength;
191
+ const rowCount = state.hasNextPage ? rowLength + 1 : rowLength;
192
192
  // Auto load data when current page is 0
193
- if (currentPage === 0 && stateAutoLoad)
193
+ if (state.currentPage === 0 && state.autoLoad)
194
194
  loadDataLocal();
195
195
  // Layout
196
196
  return (React.createElement(React.Fragment, null,
@@ -53,7 +53,7 @@ export const ScrollerList = (props) => {
53
53
  // Update state
54
54
  state.isNextPageLoading = true;
55
55
  // Parameters
56
- const { currentPage, batchSize, orderBy, orderByAsc, data, isMounted } = state;
56
+ const { currentPage, batchSize, orderBy, orderByAsc, data } = state;
57
57
  const loadProps = {
58
58
  currentPage,
59
59
  batchSize,
@@ -62,10 +62,10 @@ export const ScrollerList = (props) => {
62
62
  data
63
63
  };
64
64
  loadData(loadProps).then((result) => {
65
- state.isMounted = true;
66
- if (result == null || isMounted === false) {
65
+ if (result == null || state.isMounted === false) {
67
66
  return;
68
67
  }
68
+ state.isMounted = true;
69
69
  const newItems = result.length;
70
70
  state.lastLoadedItems = newItems;
71
71
  state.hasNextPage = newItems >= loadBatchSize;
@@ -121,7 +121,8 @@ export const ScrollerList = (props) => {
121
121
  };
122
122
  Object.assign(state, resetState);
123
123
  // Reset
124
- setRows([]);
124
+ if (state.isMounted !== false)
125
+ setRows([]);
125
126
  },
126
127
  scrollTo(scrollOffset) {
127
128
  refMethods.scrollTo(scrollOffset);
@@ -160,8 +161,7 @@ export const ScrollerList = (props) => {
160
161
  state.isMounted = false;
161
162
  };
162
163
  }, []);
163
- // Destruct state
164
- const { autoLoad: stateAutoLoad, hasNextPage, currentPage } = state;
164
+ // Row count
165
165
  const rowCount = rows.length;
166
166
  // Local items renderer callback
167
167
  const onItemsRenderedLocal = (props) => {
@@ -175,9 +175,9 @@ export const ScrollerList = (props) => {
175
175
  onItemsRendered(props);
176
176
  };
177
177
  // Item count
178
- const itemCount = hasNextPage ? rowCount + 1 : rowCount;
178
+ const itemCount = state.hasNextPage ? rowCount + 1 : rowCount;
179
179
  // Auto load data when current page is 0
180
- if (currentPage === 0 && stateAutoLoad)
180
+ if (state.currentPage === 0 && state.autoLoad)
181
181
  loadDataLocal();
182
182
  // Layout
183
183
  return typeof itemSize === 'function' ? (React.createElement(VariableSizeList, { height: height, width: width, itemCount: itemCount, itemSize: itemSize, outerRef: refs, ref: listRef, style: style, onItemsRendered: onItemsRenderedLocal, ...rest }, itemRendererLocal)) : (React.createElement(FixedSizeList, { height: height, width: width, itemCount: itemCount, itemSize: itemSize, outerRef: refs, ref: listRef, style: style, onItemsRendered: onItemsRenderedLocal, ...rest }, itemRendererLocal));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.4.31",
3
+ "version": "1.4.32",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -198,8 +198,7 @@ export const ScrollerGrid = <T extends Record<string, unknown>>(
198
198
  state.isNextPageLoading = true;
199
199
 
200
200
  // Parameters
201
- const { currentPage, batchSize, orderBy, orderByAsc, data, isMounted } =
202
- state;
201
+ const { currentPage, batchSize, orderBy, orderByAsc, data } = state;
203
202
 
204
203
  const loadProps: GridLoadDataProps = {
205
204
  currentPage,
@@ -210,11 +209,10 @@ export const ScrollerGrid = <T extends Record<string, unknown>>(
210
209
  };
211
210
 
212
211
  loadData(loadProps).then((result) => {
213
- state.isMounted = true;
214
-
215
- if (result == null || isMounted === false) {
212
+ if (result == null || state.isMounted === false) {
216
213
  return;
217
214
  }
215
+ state.isMounted = true;
218
216
 
219
217
  const newItems = result.length;
220
218
  state.lastLoadedItems = newItems;
@@ -291,7 +289,7 @@ export const ScrollerGrid = <T extends Record<string, unknown>>(
291
289
  Object.assign(state, resetState);
292
290
 
293
291
  // Reset items
294
- setRows([]);
292
+ if (state.isMounted !== false) setRows([]);
295
293
  };
296
294
 
297
295
  React.useImperativeHandle(
@@ -378,15 +376,14 @@ export const ScrollerGrid = <T extends Record<string, unknown>>(
378
376
  });
379
377
  }, [width]);
380
378
 
381
- // Destruct state
382
- const { autoLoad: stateAutoLoad, hasNextPage, currentPage } = state;
379
+ // Rows
383
380
  const rowLength = rows.length;
384
381
 
385
382
  // Row count
386
- const rowCount = hasNextPage ? rowLength + 1 : rowLength;
383
+ const rowCount = state.hasNextPage ? rowLength + 1 : rowLength;
387
384
 
388
385
  // Auto load data when current page is 0
389
- if (currentPage === 0 && stateAutoLoad) loadDataLocal();
386
+ if (state.currentPage === 0 && state.autoLoad) loadDataLocal();
390
387
 
391
388
  // Layout
392
389
  return (
@@ -163,8 +163,7 @@ export const ScrollerList = <T extends Record<string, any>>(
163
163
  state.isNextPageLoading = true;
164
164
 
165
165
  // Parameters
166
- const { currentPage, batchSize, orderBy, orderByAsc, data, isMounted } =
167
- state;
166
+ const { currentPage, batchSize, orderBy, orderByAsc, data } = state;
168
167
 
169
168
  const loadProps: GridLoadDataProps = {
170
169
  currentPage,
@@ -175,11 +174,10 @@ export const ScrollerList = <T extends Record<string, any>>(
175
174
  };
176
175
 
177
176
  loadData(loadProps).then((result) => {
178
- state.isMounted = true;
179
-
180
- if (result == null || isMounted === false) {
177
+ if (result == null || state.isMounted === false) {
181
178
  return;
182
179
  }
180
+ state.isMounted = true;
183
181
 
184
182
  const newItems = result.length;
185
183
  state.lastLoadedItems = newItems;
@@ -250,7 +248,7 @@ export const ScrollerList = <T extends Record<string, any>>(
250
248
  Object.assign(state, resetState);
251
249
 
252
250
  // Reset
253
- setRows([]);
251
+ if (state.isMounted !== false) setRows([]);
254
252
  },
255
253
 
256
254
  scrollTo(scrollOffset: number): void {
@@ -301,8 +299,7 @@ export const ScrollerList = <T extends Record<string, any>>(
301
299
  };
302
300
  }, []);
303
301
 
304
- // Destruct state
305
- const { autoLoad: stateAutoLoad, hasNextPage, currentPage } = state;
302
+ // Row count
306
303
  const rowCount = rows.length;
307
304
 
308
305
  // Local items renderer callback
@@ -319,10 +316,10 @@ export const ScrollerList = <T extends Record<string, any>>(
319
316
  };
320
317
 
321
318
  // Item count
322
- const itemCount = hasNextPage ? rowCount + 1 : rowCount;
319
+ const itemCount = state.hasNextPage ? rowCount + 1 : rowCount;
323
320
 
324
321
  // Auto load data when current page is 0
325
- if (currentPage === 0 && stateAutoLoad) loadDataLocal();
322
+ if (state.currentPage === 0 && state.autoLoad) loadDataLocal();
326
323
 
327
324
  // Layout
328
325
  return typeof itemSize === 'function' ? (