Skip to content

Commit

Permalink
Improve the reset feature
Browse files Browse the repository at this point in the history
  • Loading branch information
garryxiao committed May 8, 2024
1 parent 21878e7 commit a95cc55
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@etsoo/react",
"version": "1.7.36",
"version": "1.7.37",
"description": "TypeScript ReactJs UI Independent Framework",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -65,7 +65,7 @@
"@babel/preset-env": "^7.24.5",
"@babel/runtime-corejs3": "^7.24.5",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.6",
"@testing-library/react": "^15.0.7",
"@types/jest": "^29.5.12",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
Expand Down
6 changes: 4 additions & 2 deletions src/components/ScrollerGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,19 @@ export const ScrollerGrid = <T extends object>(props: ScrollerGridProps<T>) => {

// Reset the state and load again
const reset = (add?: Partial<GridLoaderStates<T>>, items: T[] = []) => {
const { queryPaging, ...rest } = add ?? {};
const resetState: Partial<GridLoaderStates<T>> = {
queryPaging: {
...refs.current.queryPaging,
currentPage: 0
currentPage: 0,
...queryPaging
},
autoLoad: true,
loadedItems: 0,
hasNextPage: true,
isNextPageLoading: false,
lastLoadedItems: undefined,
...add
...rest
};
Object.assign(refs.current, resetState);

Expand Down
6 changes: 4 additions & 2 deletions src/components/ScrollerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,19 @@ export const ScrollerList = <T extends object>(props: ScrollerListProps<T>) => {

// Reset the state and load again
const reset = (add?: Partial<GridLoaderStates<T>>, items: T[] = []) => {
const { queryPaging, ...rest } = add ?? {};
const resetState: Partial<GridLoaderStates<T>> = {
queryPaging: {
...stateRefs.current.queryPaging,
currentPage: 0
currentPage: 0,
...queryPaging
},
autoLoad: true,
lastLoadedItems: undefined,
loadedItems: 0,
hasNextPage: true,
isNextPageLoading: false,
...add
...rest
};
Object.assign(stateRefs.current, resetState);

Expand Down

0 comments on commit a95cc55

Please sign in to comment.