-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
[Android] fontWeight number value error if not in an array #45285
Comments
|
Just a heads up that we're currently hyperfocused on New Architecture, so we won't be able to fix this bug in the immediate future (a community PR is more than welcome though). Is there a reason why you're not moving to the New Architecture @Freddy03h ? |
I have multiple projects for my clients with different dependencies and react-native versions (from 0.71), so it's not always easy to migrate to new architecture, depending on specific native dep on the project. But we found this bug while creating types for And since the type number are also added in the Typescript definition, it can happen to Typescript users too:
Also, because it's a weird case, it's not always easy to know why this error happened. I would like to help but I have no native android skills, also I don't know why this error exist only with |
So the issue is:
I believe we do some props pre-processing if you pass an array vs if you pass a single prop. In this case it being I don't have time to debug this, but for folks interested in helping out, I would put a breakpoint here: Lines 106 to 128 in d1bf828
and investigate how the array/single-value codepath diverge. |
I am working on fixing this. |
It's a little more vicious than this because direct inline style works well |
In For Dev Mode only we are making style object immutable. So Ideally this issue should not come in production. I checked this on release build as well. It's working fine for me. The issue is only on DEV Mode |
@cortinico Here are my findings When we are creating styles using Why this is not happening in other cases?
Solution
Let me know what you think. I can raise the PR for same |
@shubhamguptadream11 Effectively I can't reproduce the error on release mode, so it's dev mode only. And your change https://github.com/facebook/react-native/pull/45299/files fix the issue, thank you! |
@Freddy03h Thanks for checking this. So I am waiting for inputs from @cortinico. |
freeze make sense while development we preventing user to modify style and I have added extra layer that also removed on release. that time it check if object is freeze than only its return new object Share your suggestions into https://github.com/facebook/react-native/pull/45299/files PR @cortinico |
Addressing in #45340 |
FlowFixMe it is also there in your PR why you need it. i think its not proper solution of it. @cortinico i think now you have to raised a pr (Please read my 1st PR comments first and provide us feedback, why it's closed without any proper valid reason) |
@javache you have to do changes in |
remaining things from your PR, i have added inside #45932, could you please review it |
@Freddy03h so this issue is only happening on which specific version of react native ? few people here in discussion saying that it only happening in dev mode |
@mahishdino since 0.71.0 to the latest version available when I created this issue : 0.74.3, I didn't test it on newer version. |
Summary: flattenStyle may return an object which is already frozen (in development), so it is incorrect to further mutate this. related to #45285 ## Changelog: [GENERAL] [FIXED] - fixed fontWeight number value error for text optimized Pull Request resolved: #45932 Reviewed By: NickGerleman Differential Revision: D61773721 Pulled By: javache fbshipit-source-id: c5e23becf3af0b4303dda7b9d48628b2bca3285a
Closing as the linked PR has been merged |
Thank you! 😃 |
Description
fontWeight
accept number values since0.71
But there is an issue on Android on a specific case:
It's only happen on the old Architecture (no issue with new arch) and with a style created with
Stylesheet.create
and given tostyle
prop directly, not in an array.style from Stylesheet.create directly passed to style prop
style from Stylesheet.create given to style prop in an array
inline style
style not created with
Stylesheet.create
Steps to reproduce
npx react-native init
React Native Version
0.74.3
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/Freddy03h/react-native-font-weight-number-android-issue
Screenshots and Videos
The text was updated successfully, but these errors were encountered: