-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[data grid] Doesn't work with Preact #12829
Comments
Thanks for raising this issue @vsacom ... I have added it to our board! |
@vsacom Have you considered opening an issue with preact? The component runs fine under react, and if there is a difference when run under preact I would tend to think that preact's compatibility mode is failing one way or another. |
I have not reported this to Preact yet as the issue appeared just on the update of MUI-X. |
No idea, I don't know what preact does and how it differs from react, and why it also differs in dev/prod modes. If you open an issue with them, they can probably provide more information that we could use to assist on our side. Our codebase is a pretty standard react codebase. |
To copy my reply from the Preact thread: Preact doesn't support using Whether you consider than an issue here or not, up to you, but thought I'd mention it. |
Thanks for the feedback. Out of curiosity, why would you not support @vsacom I think I would consider this a bug in preact as it doesn't behaves the same as react does. I'm not against making small changes to the datagrid to make it work with preact as it offers benefits compared to react, but for this issue specifically I wouldn't support it. My thinking is that fixing this individual case still leaves you open to runtime production bugs of other instances of this issue that might be unnoticed at the moment, so fixing the root cause is much safer than working around individual cases like this one. I would suggest to look into running a build of the PR that fixes the issue for your production builds. I could also suggest running react in dev mode and preact in prod mode, I've done it in the past and with proper testing to catch the few incompatibilities present, it offers the best of both worlds. |
It's the same issue as trying to put an object in a dependency array. Preact has never aimed for 100% compatibility and this seems like something we shouldn't support (IMO, not speaking for the team).
Absolutely do not do this, you will run into unexpected bugs and we cannot recommend against this enough. It's a very, very bad idea to run different pieces of software in dev & prod. I know a few years ago someone on the NextJS team was promoting this but we've had dozens of users run into nasty surprises doing this. On the Preact thread I gave some better options, such as patching out the error from |
Importantly, it's incorrect if
All dependencies should be carefully evaluated, yes. Passing around
The Preact 10.x line supports IE11, I'm not trying to change your mind, fwiw, just explaining why we don't (and perhaps won't) support this. We have the issue, workaround, & PR on our tracker which should address this reasonably. |
You could use a shim as a fallback,
But not necessarily, it can also denote "not applicable", e.g. requests/seconds when there hasn't been any data yet (
👍 I do think you should change your position on this issue but don't feel obligated to reply. |
We have tight size constraints.
It's much more typical to fallback to another value immediately, usually |
While I agree with Romain's points that I wouldn't aim for 100% compatibility with @romgrk What do you think? |
I like preact and I'm ok with making efforts to support it, but I'm worried we're just hiding an issue that could pop up at runtime again. I see value in being "definitely broken" rather than "possibly broken". Preact doesn't support
Yeah I'm ok with that, it would at least indicate interest in using the partial fix. |
The issue has been inactive for 7 days and has been automatically closed. |
The fix for this issue would probably be this: diff --git a/packages/x-data-grid/src/components/virtualization/GridVirtualScrollbar.tsx b/packages/x-data-grid/src/components/virtualization/GridVirtualScrollbar.tsx
index 5be8dfaf89..5feb8eaf8e 100644
--- a/packages/x-data-grid/src/components/virtualization/GridVirtualScrollbar.tsx
+++ b/packages/x-data-grid/src/components/virtualization/GridVirtualScrollbar.tsx
@@ -97,7 +97,7 @@ const GridVirtualScrollbar = React.forwardRef<HTMLDivElement, GridVirtualScrollb
: dimensions.viewportOuterSize.width;
const scrollbarInnerSize =
- scrollbarSize * (contentSize / dimensions.viewportOuterSize[propertyDimension]);
+ scrollbarSize * (contentSize / dimensions.viewportOuterSize[propertyDimension]) || 0;
const onScrollerScroll = useEventCallback(() => {
const scroller = apiRef.current.virtualScrollerRef.current!; |
The issue has been inactive for 7 days and has been automatically closed. |
Thank you for the efforts from both Mui and Preact side. The solution proposed by @cherniavskii looks promising and it's working in initial testing. |
You can add here, but I would recommend patching preact as it's a more robust way of fixing the issue, not only for the datagrid but also for any other react component you might be using. Also note that we're going to wait for an external PR for this issue, if you're interested you can submit one. |
FWIW, we've received one issue report (this one) in a year of throwing upon encountering This doesn't seem to be all that common of a practice. |
Steps to reproduce
Link to live example: Codesandbox: https://codesandbox.io/p/devbox/datagridpro-test-7-2-0-47rlrc
Steps:
Attached is a simplified example:
datagrid_720_preact.zip
Current behavior
The Datagrid appears multiple times when running in development mode.
This concerns both DataGrid and DataGridPro after updating version from v6 to v7.
Note that preview-mode (npm run preview, build&serve) displays the DataGrid just once.
Expected behavior
The Datagrid appears only once
Context
No response
Your environment
npx @mui/envinfo
Search keywords: datagrid preact
Order ID: 82100
The text was updated successfully, but these errors were encountered: