-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Each hook should initialize its state synchronously #2782
Merged
Conversation
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
github-actions
bot
added
the
PR: out-of-date
The pull request has merge conflicts and can't be merged
label
Oct 5, 2021
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
github-actions
bot
removed
the
PR: out-of-date
The pull request has merge conflicts and can't be merged
label
Oct 5, 2021
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
github-actions
bot
added
the
PR: out-of-date
The pull request has merge conflicts and can't be merged
label
Oct 5, 2021
github-actions
bot
removed
the
PR: out-of-date
The pull request has merge conflicts and can't be merged
label
Oct 6, 2021
flaviendelangle
added
breaking change
component: data grid
This is the name of the generic UI component, not the React module!
core
Infrastructure work going on behind the scenes
labels
Oct 6, 2021
This was referenced Oct 9, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
breaking change
component: data grid
This is the name of the generic UI component, not the React module!
core
Infrastructure work going on behind the scenes
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2293
Part of #924
Overview
useGridColumnReorder
,useGridColumnResize
anduseGridInfiniteLoader
. Instead, the feature hook should inject the props inprops.componentsProps?.XXX
I plan to rework the folder structure in a future PR to put back the pro-only features inside the
data-grid-pro
folder to be able to ban the imports fromdata-grid
todata-grid-pro
with ESLint.Breaking changes
Merge
state.visibleRows
andstate.filter
intostate.filter
Rename
getInitialGridFilterState
intogetDefaultGridFilterModel
Remove
getInitialGridSortingState
Remove other initialize method
Detailed structure of a feature hook
I did not reorder the elements of every feature hooks because the order does not always cause bugs.
For instance, if you instantiate the api methods after the events listeners, it only cause problems if one of the event listeners is an api method (ex:
useGridApiEventHandler(apiRef, GridEvents.rowsSet, apiRef.current.applyFilters);
).But we should use the following order as much as possible to avoid any issue.
Concerning the hook order, the following hook should be after
useGridSomeOtherFeature
as it uses its state in the render phase.If possible it should be after
useGridRows
as it depends on it, but if for some reason you have to put it after, it would work.The dependance is asynchronous (the
GridEvents.rowsSet
is published through auseEffect
) souseGridExample
would already be initialized for the 1st event publication even if its after in the feature list).