You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Theme updates stop working when React Compiler is enabled, in components structured like the example above
Issue occurs regardless of whether style prop is provided
Using unistyles themes directly in style prop also doesn't update
Attempted Solution:
I tried wrapping the component with createUnistylesComponent. This fixed the theme updating, but introduced re-rendering on theme changes, which defeats the no-rerender benefit of Unistyles 3.0.
Test cases:
Works: Without React Compiler
Works: Without style prop definition (Please check ThemedView in reproduction)
Doesn't work: With React Compiler + style prop definition (Please check UnistyledView in reproduction)
Works but re-renders: With React Compiler + style prop definition + createUnistylesComponent
Although such component patterns might not be necessary when fully adopting Unistyles, developers migrating from React Native's StyleSheet might encounter this issue.
Thank you for looking into this! Totally understand about waiting for a later beta given React Compiler's current status. Really appreciate the quick response! 🙏
Description
When using React Compiler, theme updates don't work in components that:
Example of affected component:
Details:
Attempted Solution:
I tried wrapping the component with
createUnistylesComponent
. This fixed the theme updating, but introduced re-rendering on theme changes, which defeats the no-rerender benefit of Unistyles 3.0.Test cases:
Works: Without React Compiler
Works: Without style prop definition (Please check ThemedView in reproduction)
Doesn't work: With React Compiler + style prop definition (Please check UnistyledView in reproduction)
Works but re-renders: With React Compiler + style prop definition +
createUnistylesComponent
Although such component patterns might not be necessary when fully adopting Unistyles, developers migrating from React Native's StyleSheet might encounter this issue.
Steps to Reproduce
Snack or Repository Link (Optional)
https://github.com/Ucekay/unistyles-react-compiler-repro
Unistyles Version
3.0.0-beta.1
React Native Version
0.76.3
Platforms
iOS
Expo
Yes
The text was updated successfully, but these errors were encountered: