-
Notifications
You must be signed in to change notification settings - Fork 84
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
fix useAppColorScheme hook to return correct scheme #266
Conversation
thanks for the PR. i think you're correct that this is a bug. i want to do a little deeper looking and testing, but my initial thought is that you're correct. i'll try to get back to you shortly on this. |
hey, thanks for your patience. i spend some time thinking about this yesterday, and i think the heart of the issue is that using as I worked on this a bit, i remembered someone else pointing out this exact issue, although i didn't realize what it was, and that it was a bug in the library. see these two comments:
so, having considered that, it seemed to me that the more correct fix would be to initialize properly, rather than abandon the documented fallback to the ambient device colorscheme. i worked up a PR for that, i was wondering if you would mind looking at it, and let me know if you see any problems with the approach, and specifically if it would also solve the issue you're having that led you to create this PR: if you wanted to try it out in your app, i published that PR's code to npm as |
Thank you for looking into this!
Having re-read the documentation, I can see that my understanding of In addition, I was trying to use That made me realise that like |
that's really helpful feedback, thanks. even though the fix i'm proposing makes the library work the way the documentation suggests, there's a visible change in behavior, and i was pondering whether it should technically be a breaking change to fix the bug for the exact reason you mention -- it could cause apps to suddenly start initializing to dark when they hadn't before. but then, if i'm going to make a breaking semver change, i'm not sure i want to keep this exact API. i was worried about the other thing you mentioned too - as it stands now, so i don't love the api, and if i'm going to a breaking change, i'm wondering if it would be better just to fix it in a more intuitive way. to eliminate the initialization param of useDeviceContext(tw, {
withDeviceColorScheme: false,
initialColorScheme: `light`, // 👍 <-- new, optional ???
}) |
Moving the initial colour scheme to |
closing for #271 |
When a device is in dark mode and you set withDeviceColorScheme to false, the application renders in light mode as expected.
However, in contrast to what is rendered, the
useAppColorScheme
hook incorrectly indicates that the application is in dark mode.Unless I'm mistaken, it looked like
useAppColorScheme
was completely decoupled from twrnc's colour scheme. I'm not sure if this was intentional for any reason? If not, doesuseAppColorScheme
'sinitialValue?: RnColorScheme
actually have a use case?