[useStyles] Prop passing after v5 migration
See original GitHub issueDuplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
We are trying to migrate from v4 to v5 and we use a lot of makeStyles and useStyles. We are trying to migrate the style component and apply the styled code mode, but many files are throwing errors. For example, we use useStyles for prop pass, but the code mod using useStyles was deleted, but props remained idle. And naturally the app doesn’t compile.
Expected behavior 🤔
We don’t know how to use the props we give to useStyles when using styled-component. If we know what we can use instead of use useStyles, we can apply it.
Your environment 🌎
`npx @mui/envinfo`
System:
OS: Windows 10 10.0.19043
Binaries:
Node: 14.18.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.15 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Spartan (44.19041.1266.0), Chromium (96.0.1054.34)
npmPackages:
@emotion/react: ^11.6.0 => 11.6.0
@emotion/styled: ^11.6.0 => 11.6.0
@mui/base: 5.0.0-alpha.55
@mui/codemod: ^5.1.1 => 5.1.1
@mui/icons-material: ^5.1.1 => 5.1.1
@mui/lab: ^5.0.0-alpha.55 => 5.0.0-alpha.55
@mui/material: ^5.1.1 => 5.1.1
@mui/private-theming: 5.1.1
@mui/styled-engine: 5.1.1
@mui/styles: ^5.1.1 => 5.1.1
@mui/system: ^5.1.1 => 5.1.1
@mui/types: ^7.1.0 => 7.1.0
@mui/utils: 5.1.1
@types/react: 16.9.56
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
styled-components: 3.4.10
typescript: 3.5.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
[useStyles] Prop passing after v5 migration #29904 - GitHub
We are trying to migrate the style component and apply the styled code mode, but many files are throwing errors. For example, we...
Read more >Breaking changes in v5, part one: styles and themes - MUI
This is a reference guide to all of the breaking changes introduced in Material v5, and how to handle them when migrating from...
Read more >Passing props to MUI styles - reactjs - Stack Overflow
In MUI v5, this is how you access the props when creating the style object using styled() : import { styled } from...
Read more >Material UI 5 - the easiest way to migrate from makeStyles to ...
We setup the ThemeProvider and StylesProvider in our root component; We create a custom hook useStyles; We get rid of the makeStyles and...
Read more >makeStyles -> useStyles - Setup
const useStyles = makeStyles()({. //If you don't need neither the theme nor any state or. //props to describe your component style you can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@cengizcmataraci as far as I can see the API you are using is not correct. Check https://mui.com/styles/basics/#adapting-based-on-props
On the other hand, if you wish to adopt to v5, you can use
styled()
orsx
prop, or migrate totss-react
for using an API similar tomakeStyles
. I hope this helps.I also get the error “Transformation error (Unexpected token (168:2)) SyntaxError: Unexpected token (168:2)” when I refer to the styled code mode, and another 116 files also get an error.