We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Render any component with sx usage like this will throw an Error Cannot read property 'applyStyles' of undefined:
sx
Cannot read property 'applyStyles' of undefined
<Box sx={theme => ({ backgroundSize: 'cover', backgroundPosition: 'center', minHeight: 280, backgroundImage: 'var(--Image-light)', ...theme.applyStyles('dark', { backgroundImage: 'var(--Image-dark)', }), })}
The correct syntax for using theme from sx prop is to declare a parameter, not object pattern ({ theme })
theme
({ theme })
The sx prop should work with sx={theme => …}
sx={theme => …}
I am working on a codemod for transforming sx prop and I stumbled on this error.
npx @mui/envinfo
Don't forget to mention which browser you used. Output from `npx @mui/envinfo` goes here.
Search keywords: sx theme
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Steps to reproduce
Render any component with
sx
usage like this will throw an ErrorCannot read property 'applyStyles' of undefined
:Current behavior
The correct syntax for using
theme
fromsx
prop is to declare a parameter, not object pattern({ theme })
Expected behavior
The
sx
prop should work withsx={theme => …}
Context
I am working on a codemod for transforming
sx
prop and I stumbled on this error.Your environment
npx @mui/envinfo
Search keywords: sx theme
The text was updated successfully, but these errors were encountered: