-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Make readonly object editable for change style object attributes #45299
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
Make readonly object editable for change style object attributes #45299
Conversation
Hi @meetdhanani17! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This doesn't seem right to me. If the value we receive is frozen, we do not want to make an extra copy here for what will be a very common scenario. This is a perf-sensitive code-path, let's be careful with changes here (eg with is the cost of calling isFrozen?) |
As you know about the styles it's doing frozen when enviroment is dev in ptoduction all the cost of reassign an object removed becuase we will not get frozon object that time, and when an object came in list then we are also regenerating an object, as it is development environment different it doesn't change in production/release |
For the preventing of style object attributes change by end development, i haven't removed freeze object return while style create using create method |
It's not clear what this PR enables? It is desirable for the output of flattenStyle to not be mutable and it shouldn't be assumed to be. |
but this also make an array mutable that's what I want to tell you, and it is only occurs problem when we are try to change immutable change (but my question again is why we are try to change immutable object) |
|
We should address the root cause here, which does seem to be the text component, we shouldn't be mutating the return value of flattenStyle. I'd recommend changing Text.js like this instead (the $FlowFixMe's there a clear sign the API boundary is not respected)
|
I will send a PR for this. |
#45340 addresses this issue. |
Ok great, but i'm am also working on native side for fix it |
That what i have talked with you, like i have multiple ways to solve this issue if you said to change only text file then i'll fix using only Text.js file and you can compare here i have removed FlowFixMe's while return mutable object |
Summary:
Fixes #45285
object created by StyleSheet.create provide readonly object and it cannot be changeable for farther value or type change according to native requirements, so I have added condition in flattenStyle function, if it's readonly than convert into editable object
Changelog:
[GENERAL] [FIXED] - fixed fontWeight number value error for android (java.lang.Double cannot be cast to java.lang. String)