From 7216079a7915fe3b06de72a831c22a6bb4ff1aad Mon Sep 17 00:00:00 2001 From: Eli White Date: Thu, 1 Mar 2018 16:53:36 -0800 Subject: [PATCH] Avoid var specific hoisting rules Reviewed By: sahrens Differential Revision: D7116184 fbshipit-source-id: 4fd1654028e52f5aafad348546b889f1737c7399 --- .../ActivityIndicator/ActivityIndicator.js | 17 +++++++++-------- Libraries/Components/TextInput/TextInput.js | 10 +++++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/Libraries/Components/ActivityIndicator/ActivityIndicator.js index 6f9d34966..a520b6579 100644 --- a/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -21,6 +21,7 @@ const ViewPropTypes = require('ViewPropTypes'); const createReactClass = require('create-react-class'); const requireNativeComponent = require('requireNativeComponent'); +let RCTActivityIndicator; const GRAY = '#999999'; @@ -120,6 +121,14 @@ const ActivityIndicator = createReactClass({ } }); +if (Platform.OS === 'ios') { + RCTActivityIndicator = requireNativeComponent( + 'RCTActivityIndicatorView', + ActivityIndicator, + { nativeOnly: { activityIndicatorViewStyle: true } } + ); +} + const styles = StyleSheet.create({ container: { alignItems: 'center', @@ -135,12 +144,4 @@ const styles = StyleSheet.create({ }, }); -if (Platform.OS === 'ios') { - var RCTActivityIndicator = requireNativeComponent( - 'RCTActivityIndicatorView', - ActivityIndicator, - { nativeOnly: { activityIndicatorViewStyle: true } } - ); -} - module.exports = ActivityIndicator; diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 383e7e6ac..6b812a2cf 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -39,6 +39,10 @@ const requireNativeComponent = require('requireNativeComponent'); * run Flow. */ const warning = require('fbjs/lib/warning'); +let AndroidTextInput; +let RCTMultilineTextInputView; +let RCTSinglelineTextInputView; + const onlyMultiline = { onTextInput: true, children: true, @@ -47,13 +51,13 @@ const onlyMultiline = { import type {ViewChildContext} from 'ViewContext'; if (Platform.OS === 'android') { - var AndroidTextInput = requireNativeComponent('AndroidTextInput', null); + AndroidTextInput = requireNativeComponent('AndroidTextInput', null); } else if (Platform.OS === 'ios') { - var RCTMultilineTextInputView = requireNativeComponent( + RCTMultilineTextInputView = requireNativeComponent( 'RCTMultilineTextInputView', null, ); - var RCTSinglelineTextInputView = requireNativeComponent( + RCTSinglelineTextInputView = requireNativeComponent( 'RCTSinglelineTextInputView', null, );