-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
Material UI styled component not releasing DOM Nodes after rerender #36294
Comments
Can you please share a repository that can be cloned? I know you have listed all steps, but it is much easier for maintainers if we don't need to set up from start new project for every issue. Sharing a codesandbox would also work. |
sure, here the link to my repository: https://github.com/handoiditu1508/mui-memory-leak-bug |
Perfect, thanks! I will have a look tomorrow. |
I can't reproduce this in production. However, the styles changing on each drag means that new class names are being generated. Honestly I would not recommend doing this, if a style depends on something this dynamic, it should probably be defined inside the Sorry for tagging you earlier @Andarist :D |
Thanks @mnajdova! You are right, after I update my code to use |
Thanks @mnajdova for looking into this. Is the guidance then not to use the |
Duplicates
Latest version
Steps to reproduce 🕹
Repository to live example: https://github.com/handoiditu1508/mui-memory-leak-bug
Steps:
npx create-react-app my-app --template typescript
cd my-app
npm install @emotion/react @emotion/styled @mui/material
App.tsx
:my
package.json
file:npm start
I using Microsoft Edge Version 110.0.1587.50 (Official build) (64-bit).
I didn't test on other browser.
Current behavior 😯
The DOM Nodes keep increasing without decreasing, in the pictures, DOM Nodes start at 182, I click the button multiple times to cause components trigger rerender gradually, after few minutes, DOM Nodes can reach 1710.
This is just a very simple app with no special effect.
Expected behavior 🤔
The DOM Nodes should be released after sometime.
Context 🔦
When I test it with non-styled or styled component without
shouldForwardProp
option, the DOM Nodes are released after few minutes. (See all the cases I tested in myApp.tsx
file)This might doesn't seem that bad, just more than 1000 DOM Nodes unreleased.
But I'm having an app with multiple components that use
styled()
function withshouldForwardProp
option and some MUISlider with very small step, those styled components will rerender whenever I change the Slider value. My app can reach up to 50.000+ DOM Nodes easily and getting lagger everytime I change the slider value.Your environment 🌎
npx @mui/envinfo
tsconfig.json
The text was updated successfully, but these errors were encountered: