Skip to content
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

The darkMode and lightMode Toggle breaks #25256

Closed
2 tasks done
milindvishnoi opened this issue Mar 7, 2021 · 4 comments
Closed
2 tasks done

The darkMode and lightMode Toggle breaks #25256

milindvishnoi opened this issue Mar 7, 2021 · 4 comments
Labels
duplicate This issue or pull request already exists v4.x

Comments

@milindvishnoi
Copy link

milindvishnoi commented Mar 7, 2021

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

As of now, I have creates a Switch in my App, this Switch is used to switch the theme. The theme seems to change when the button is clicked once but stops working after that.

Expected Behavior 🤔

Keep switching every time the theme is toggled.

Steps to Reproduce 🕹

Steps:

  1. Create 2 themes (darkTheme, lightTheme) using createMuiTheme
  2. create a darkMode state which stores boolean value depicting the current theme mode
  3. create a toggle theme to switch darkMode
  4. Create a Switch using MUI and then using that switch to toggleTheme
  5. Add a ThemeProvider in the App.js file that contains all the other components like this <ThemeProvider theme={darkMode ? darkTheme : lightTheme}>

Context 🔦

I am trying to make a dark mode feature to my website to make it more attractive and fun to use.

Your Environment 🌎

`npx @material-ui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @material-ui/envinfo` goes here.

System:
OS: macOS 11.1
Binaries:
Node: 12.16.2 - ~/.nvm/versions/node/v12.16.2/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.5 - ~/.nvm/versions/node/v12.16.2/bin/npm
Browsers:
Chrome: 89.0.4389.82
Edge: Not Found
Firefox: Not Found
Safari: 14.0.2
npmPackages:
@material-ui/core: ^4.11.3 => 4.11.3
@material-ui/lab: ^4.0.0-alpha.57 => 4.0.0-alpha.57
@material-ui/styles: 4.11.3
@material-ui/system: 4.11.3
@material-ui/types: 5.1.0
@material-ui/utils: 4.11.2
@types/react: 17.0.2
react: ^17.0.1 => 17.0.1
react-dom: ^17.0.1 => 17.0.1

@milindvishnoi milindvishnoi added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 7, 2021
@oliviertassinari oliviertassinari added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 7, 2021
@oliviertassinari
Copy link
Member

Please provide a minimal reproduction test case. This would help a lot 👷 .
A live example would be perfect. This codesandbox.io template may be a good starting point. Thank you!

@milindvishnoi
Copy link
Author

@oliviertassinari oliviertassinari added duplicate This issue or pull request already exists and removed status: waiting for author Issue with insufficient information labels Mar 7, 2021
@oliviertassinari
Copy link
Member

Duplicate of #18018

@oliviertassinari oliviertassinari marked this as a duplicate of #18018 Mar 7, 2021
@oliviertassinari
Copy link
Member

It's a well-known bug. global styles aren't cleaned up strict mode in v4. Remove the strict mode wrapper or upgrade to v5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists v4.x
Projects
None yet
Development

No branches or pull requests

2 participants