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

useColorScheme should fail when not called under a ThemeProvider #43952

Open
Janpot opened this issue Oct 1, 2024 · 0 comments
Open

useColorScheme should fail when not called under a ThemeProvider #43952

Janpot opened this issue Oct 1, 2024 · 0 comments
Assignees
Labels
customization: theme Centered around the theming features

Comments

@Janpot
Copy link
Member

Janpot commented Oct 1, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/embed/8clfj3?module=/src/Demo.tsx

Try toggling the theme with the two selects

Current behavior

The first one select box doesn't do anything. There is no feedback to the developer that the first call to useColorScheme will never work.

Expected behavior

The call to useColorScheme errors when there is no theme available.

Context

Potentially what this user ran in to.

Orthogonal issue, but I started from this example. It would be more ergonomic if these were radio buttons, or toggle buttons. It halves the amount of clicks necessary to operate the demo.

Your environment

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

Search keywords: useColorScheme ThemeProvider

@Janpot Janpot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 1, 2024
@Janpot Janpot added customization: theme Centered around the theming features and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customization: theme Centered around the theming features
Projects
None yet
Development

No branches or pull requests

2 participants