mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.07k stars 1.26k forks source link

[data grid]: Infinite Re-render when adding custom Data Grid Row #11683

Closed yelnyafacee closed 8 months ago

yelnyafacee commented 8 months ago

Steps to reproduce

Link to live example: (required)

Steps:

  1. add: slots={{ row: (props) => { return (

    {"extra row below"}
        );
      },
    }} to <DataGrid />

Current behavior

stuck in infinite re-render, Data Grid width keeps expanding horizontally

Expected behavior

no infinite re-render, should show custom row with 2x child row in it

Context

I am using MUI Data Grid and I would want to make something like this with it:

Screenshot_127

issue shown in codesandbox: https://codesandbox.io/p/sandbox/small-https-d8dm88?file=%2Fdemo.tsx%3A84%2C1-94%2C11

Your environment

npx @mui/envinfo ``` System: OS: Windows 11 10.0.22621 Binaries: Node: 17.8.0 - C:\Program Files\nodejs\node.EXE npm: 8.5.5 - C:\Program Files\nodejs\npm.CMD pnpm: Not Found Browsers: Chrome: Not Found Edge: Chromium (120.0.2210.133) npmPackages: @emotion/react: ^11.11.1 => 11.11.1 @emotion/styled: ^11.11.0 => 11.11.0 @mui/base: 5.0.0-beta.4 @mui/core-downloads-tracker: 5.13.4 @mui/icons-material: ^5.11.16 => 5.11.16 @mui/material: ^5.13.5 => 5.13.5 @mui/private-theming: 5.13.1 @mui/styled-engine: 5.13.2 @mui/styles: ^5.12.3 => 5.12.3 @mui/system: 5.13.5 @mui/types: 7.2.4 @mui/utils: ^5.13.1 => 5.13.7 @mui/x-data-grid: ^6.8.0 => 6.8.0 @mui/x-data-grid-generator: ^6.8.0 => 6.8.0 @mui/x-data-grid-premium: 6.8.0 @mui/x-data-grid-pro: 6.8.0 @mui/x-date-pickers: ^6.9.1 => 6.9.1 @mui/x-license-pro: 6.6.0 @types/react: 18.0.28 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 styled-components: ^5.3.6 => 5.3.6 ``` using Edge: Chromium (120.0.2210.133)

Search keywords: Data Grid Row, GridRow, Slots

michelengelen commented 8 months ago

@yelnyafacee What you are trying to do is currently not possible by just adding a different DOM structure. What happens if you try is that the internal calculations get messed up.

One thing that could work is using the master details panel for you purpose?

github-actions[bot] commented 8 months ago

The issue has been inactive for 7 days and has been automatically closed. If you think that it has been incorrectly closed, please reopen it and provide missing information (if any) or continue the last discussion.