Do not mutate output of flattenStyle in TextInput (#45348)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45348

flattenStyle may return an object which is already frozen (in development), so it is incorrect to further mutate this.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D59525418

fbshipit-source-id: 094b7c9c952d8684e24203cc07d6bda51bdf12b5
This commit is contained in:
Pieter De Baets
2024-07-09 15:58:12 -07:00
committed by Facebook GitHub Bot
parent 2bed2ab1a6
commit 57e3451557
@@ -1535,12 +1535,10 @@ function InternalTextInput(props: Props): React.Node {
};
}
const style = flattenStyle<TextStyleProp>(props.style);
let style = flattenStyle<TextStyleProp>(props.style);
if (typeof style?.fontWeight === 'number') {
// $FlowFixMe[prop-missing]
// $FlowFixMe[cannot-write]
style.fontWeight = style?.fontWeight.toString();
// $FlowFixMe
style = [style, {fontWeight: style.fontWeight.toString()}];
}
if (Platform.OS === 'ios') {