-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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(ThemeProvider): update theme with prop change #3732
Conversation
Codecov Report
@@ Coverage Diff @@
## next #3732 +/- ##
==========================================
+ Coverage 79.47% 79.85% +0.38%
==========================================
Files 87 87
Lines 1822 1822
Branches 805 804 -1
==========================================
+ Hits 1448 1455 +7
+ Misses 369 362 -7
Partials 5 5
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Thanks again for all your efforts @arpitBhalla. I think that the |
@arpitBhalla I just wanted to thank you again for your great work. Thanks so much for what you do! |
@arpitBhalla is it planned to merge this? It's seemed ready to go for many months but it still isn't merged, not to mention released. Could you provide some clarity? |
Friendly bump. I think the code changes look good. I noticed there's been no new release candidate for a while. Is it planned to release one soon? Thank you again for all of your hard work, and please don't mistake my bump for impatience. |
Co-authored-by: Khushal Agarwal <khushal.agarwal987@gmail.com>
✅ Deploy Preview for react-native-elements ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
This PR broke my I'm using a hook to determine if fonts should be scaled in the app: // These constants determine mow much bigger the font size should get based on the user's
// accessibility settings. Even if they turn the dial all the way to 11, we will only ever
// scale the fonts by these factors. This is to prevent the font size from getting too large
// and completely breaking the layout.
export const MAX_FONT_SCALE = 1.2;
export const MIN_FONT_SCALE = 0.8;
// Returns fontScaling props for Text and TextInput components
export const useFontScaling = (): Partial<TextProps> => {
const { preferenceStore } = useStores();
const fontScaling: Partial<TextProps> = React.useMemo(() => {
const afs = preferenceStore?.allowFontScaling || false;
return {
minimumFontScale: afs ? MIN_FONT_SCALE : 1, // This prevents the font from getting too small.
maxFontSizeMultiplier: afs ? MAX_FONT_SCALE : 1, // This prevents the font from getting too big.
allowFontScaling: afs, // This allows the font to be scaled.
};
}, [preferenceStore?.allowFontScaling]);
return fontScaling;
}; Then whenever it changes, i try and update the current theme: const { updateTheme } = useTheme();
const fontScalingProps = useFontScaling();
React.useEffect(()=>{
updateTheme({
components: {
Text: {
...fontScalingProps,
},
// Other rneui components as necessary
}
});
},[fontScalingProps]);
Am I updating the theme incorrectly or is this an actual regression? Some guidance would be appreciated, thanks! |
@markrickert it happens because you need to maintain object equality for the theme object after this PR (which if I'm not mistaken is how version 3.x handled it) An approach to handling this might be like:
|
Related #3665