jaredh159 / tailwind-react-native-classnames

simple, expressive API for tailwindcss + react-native
2.08k stars 84 forks source link

change theme don't effective #300

Closed Torstentjh closed 5 months ago

Torstentjh commented 5 months ago

hello,I am a newbie in react native. I have a problem and would like to ask if there is a good solution. I use the react-navigation/native library in my project. When I use toggleColorScheme or setColorScheme to change the theme in a child component, they will only change the color in the current component and will not change other components. Is there a good solution?😭

jaredh159 commented 5 months ago

hi there! please have a look at #112 -- i think what you're encountering is that issue, you may need to break the memoization as described here: https://github.com/jaredh159/tailwind-react-native-classnames?tab=readme-ov-file#memo-busting

Torstentjh commented 5 months ago

hi there! please have a look at #112 -- i think what you're encountering is that issue, you may need to break the memoization as described here: https://github.com/jaredh159/tailwind-react-native-classnames?tab=readme-ov-file#memo-busting

Thanks a lot, I didn't notice that. sry😵‍💫

Torstentjh commented 5 months ago

@jaredh159 hello,I referred to the answer in the issue and only set memoBuster in the navigator, but it still didn't work. Is it related to my nested routes? But after I try to set this attribute on both the stack route and the bottom tab, the function of switching themes is completely invalid. I really can't figure out how to solve it image

jaredh159 commented 5 months ago

I'm not sure, you may have to set the memo buster on several components. as noted in that issue, this isn't really a solved problem yet, some people have gotten it to work with their react navigation hierarchy, others seem to not be able to.

jaredh159 commented 5 months ago

closing in favor of #112