From afafbf8ec4109b7387cf66c92f21d98a62f1e4c8 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 25 Jun 2021 19:47:50 -0700 Subject: [PATCH] Log soft exception instead of crashing if ref is null on TextInput onPress Summary: See title. Changelog: [internal] Reviewed By: yungsters Differential Revision: D29410457 fbshipit-source-id: 0b9a9836baa0b5b7deb88cd73f4f634ca10c5868 --- Libraries/Components/TextInput/TextInput.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 30e87a6de92ee3..74f0113cac74ff 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -1073,7 +1073,9 @@ function InternalTextInput(props: Props): React.Node { () => ({ onPress: (event: PressEvent) => { if (props.editable !== false) { - nullthrows(inputRef.current).focus(); + if (inputRef.current != null) { + inputRef.current.focus(); + } } }, onPressIn: props.onPressIn,