-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DataGrid] Refactor rendering, remove rafUpdate (#532)
* refactored rendering, removed rafUpdate * fix lint * Update packages/grid/_modules_/grid/models/api/stateApi.ts Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> * cleanup * cleanup * refactor window to ownerdoc... * Update packages/grid/_modules_/grid/components/AutoSizer.tsx Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> * Update packages/grid/_modules_/grid/hooks/features/virtualization/useVirtualRows.ts Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> * small refact * fix bad commit review * better story * revert refactoring as breaking the tests * prettier * slow down resize debounce * make sure the tests don't rely on the resize event * no any * fine grain timer in test * hedge against weak timing guarentees of setTimeout Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
- Loading branch information
1 parent
81b4742
commit 453e2f1
Showing
15 changed files
with
86 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/grid/_modules_/grid/hooks/features/core/useGridApi.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 5 additions & 6 deletions
11
packages/grid/_modules_/grid/hooks/features/core/useGridState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
import * as React from 'react'; | ||
import { ApiRef } from '../../../models/api/apiRef'; | ||
import { useRafUpdate } from '../../utils/useRafUpdate'; | ||
import { GridState } from './gridState'; | ||
import { useGridApi } from './useGridApi'; | ||
|
||
export const useGridState = ( | ||
apiRef: ApiRef, | ||
): [GridState, (stateUpdaterFn: (oldState: GridState) => GridState) => void, () => void] => { | ||
const api = useGridApi(apiRef); | ||
const [, forceUpdate] = React.useState(); | ||
const [rafUpdate] = useRafUpdate(apiRef, () => forceUpdate((p: any) => !p)); | ||
|
||
const forceUpdate = React.useCallback( | ||
() => apiRef.current.forceUpdate(() => apiRef.current.state), | ||
[apiRef], | ||
); | ||
const setGridState = React.useCallback( | ||
(stateUpdaterFn: (oldState: GridState) => GridState) => { | ||
api.state = stateUpdaterFn(api.state); | ||
}, | ||
[api], | ||
); | ||
|
||
return [api.state, setGridState, rafUpdate]; | ||
return [api.state, setGridState, forceUpdate]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export * from './useLogger'; | ||
export * from './useRafUpdate'; | ||
export * from './useScrollFn'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.