-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[system] Fix duplicated styles in Box #33774
[system] Fix duplicated styles in Box #33774
Conversation
Actually, I believe we should just use the index 60ef467b72..3365f69e58 100644
--- a/packages/mui-system/src/createBox.js
+++ b/packages/mui-system/src/createBox.js
@@ -1,6 +1,6 @@
import * as React from 'react';
import clsx from 'clsx';
-import styled from '@mui/styled-engine';
+import styled from './styled';
import defaultStyleFunctionSx, { extendSxProp } from './styleFunctionSx';
import useTheme from './useTheme';
We would need to maybe apply this to the other system components too. Lastly, let's add test for this :) |
@mnajdova I agree with you. It would seem that If we use the index 60ef467b72..aa00bbfc6f 100644
--- a/packages/mui-system/src/createBox.js
+++ b/packages/mui-system/src/createBox.js
@@ -1,6 +1,6 @@
import * as React from 'react';
import clsx from 'clsx';
-import styled from '@mui/styled-engine';
+import styled from './styled';
import defaultStyleFunctionSx, { extendSxProp } from './styleFunctionSx';
import useTheme from './useTheme';
@@ -11,7 +11,7 @@ export default function createBox(options = {}) {
generateClassName,
styleFunctionSx = defaultStyleFunctionSx,
} = options;
- const BoxRoot = styled('div')(styleFunctionSx);
+ const BoxRoot = styled('div', { skipSx: true })(styleFunctionSx);
const Box = React.forwardRef(function Box(inProps, ref) {
const theme = useTheme(defaultTheme);
|
Even though I apply this (including a true skipSx option) to material-ui/packages/mui-system/src/Container/createContainer.tsx Lines 77 to 128 in 58b5d72
|
@iamxukai ignore what I've said, we want to keep the Box as light as we can, so just adding the |
c0e3aa9
to
933aaf1
Compare
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.
👍 Thanks for your first contribution! look forward to see more.
@iamxukai I pushed a commit to just remove will merge once the CIs are green. |
@siriwatknp sure try this and check console.log |
There is no need to const BoxWrapper = styled('div')((props: BoxWrapperProps) => ({
color: "#FFF",
backgroundImage: props.watermarkUrl ? `url(${props.watermarkUrl})` : "none"
})); |
@siriwatknp Sorry that I mean example code, what about if I want to use Paper component or something else ? |
fixes #33443
The
Box
should not forward thesx
prop to the override component. We can overwrite theshouldForwardProp
function of the@mui/styled-engine
to solve the problem.