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 doesn't return OS color scheme on first load #5575

Closed
c0nd3v opened this issue Jan 16, 2024 · 3 comments
Closed

useColorScheme doesn't return OS color scheme on first load #5575

c0nd3v opened this issue Jan 16, 2024 · 3 comments
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)

Comments

@c0nd3v
Copy link
Contributor

c0nd3v commented Jan 16, 2024

image
useColorScheme always returns 'light', and then after that it will return the correct color scheme.

Possible fix

image
https://github.com/mantinedev/mantine/blob/703bf447b1a751daee7f3c2fff9c418bd13f5779/packages/%40mantine/hooks/src/use-media-query/use-media-query.ts#L24C2-L26C4
I believe the code above to be the problem. I only see useColorScheme and useReducedMotion actually using useMediaQuery... I think removing these lines won't break anything and will fix the problem.

Why are we returning the initialValue only if its a boolean? I don't understand the purpose of this.

@c0nd3v
Copy link
Contributor Author

c0nd3v commented Jan 16, 2024

!!! P.S I am not using SSR

rtivital added a commit that referenced this issue Jan 17, 2024
…orking correctly when initial value is provided (#5575)
@rtivital rtivital added the Fixed patch Completed issues that will be published with next patch (1.0.X) label Jan 17, 2024
rtivital added a commit that referenced this issue Jan 17, 2024
…orking correctly when initial value is provided (#5575, #5549)
@rtivital
Copy link
Member

Fixed in 7.4.2

@c0nd3v
Copy link
Contributor Author

c0nd3v commented Jan 17, 2024

Just tested it on 7.4.2, it's not fixed. Actually I just need to use getInitialValueInEffect: false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)
Projects
None yet
Development

No branches or pull requests

2 participants