From f97550850bf6bda78c82846d288f9e97bd41ba65 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Tue, 9 Jul 2024 10:37:01 -0700 Subject: [PATCH] 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] Differential Revision: D59525418 --- .../Libraries/Components/TextInput/TextInput.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.js b/packages/react-native/Libraries/Components/TextInput/TextInput.js index 6f7454c155774e..55451b9772f18c 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.js @@ -1535,12 +1535,10 @@ function InternalTextInput(props: Props): React.Node { }; } - const style = flattenStyle(props.style); - + let style = flattenStyle(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') {