-
Notifications
You must be signed in to change notification settings - Fork 56
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
feat: add useDataProvider hook #1934
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1934 +/- ##
==========================================
+ Coverage 95.31% 95.33% +0.01%
==========================================
Files 52 52
Lines 3482 3492 +10
Branches 524 524
==========================================
+ Hits 3319 3329 +10
Misses 129 129
Partials 34 34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Thanks @sissbruecker for this alternative implementation. IMO, both the usage and the implementation are more conventional this way. The refactoring done for removing the dependency of the DataProvider on the Grid makes it more clear and less coupled. I'm in favor of this implementation over the one suggested in #1910. |
…rnative' into feat/use-data-provider-hook-alternative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird not to see useDataProvider
in a TS test
…rnative' into feat/use-data-provider-hook-alternative
…rnative' into feat/use-data-provider-hook-alternative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Quality Gate failedFailed conditions 4.1% Duplication on New Code (required ≤ 3%) |
This ticket/PR has been released with Hilla 24.4.0.alpha3 and is also targeting the upcoming stable 24.4.0 version. |
As an alternative to #1910, this implements a hook that returns a data provider function that can be passed to the grid:
It supports the same filter + refresh functionality as the implementation in #1910. In order to make this work, the hook returns a new data provider function reference when the filter changes or refresh is called, which in turn causes grid to reload.
This also requires making some changes to the data provider implementation itself, as it currently requires the grid element for a number of features. In order to remove the grid reference the following changes were necessary:
reset
is called on the data provider whenever the grid should be reloaded or the filter changes.The last two points don't concern developers really, as these automatisms are provided by
AutoGrid
anduseDataProvider
.