From 57e3451557568cdfcb0ef82f4027de408780466d Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Tue, 9 Jul 2024 15:58:12 -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] Reviewed By: NickGerleman Differential Revision: D59525418 fbshipit-source-id: 094b7c9c952d8684e24203cc07d6bda51bdf12b5 --- .../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 6f7454c1557..55451b9772f 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') {