From 0f42cd83e126876ba589e023337d97dc22e026e7 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Mon, 7 Sep 2015 13:00:59 -0700 Subject: [PATCH] Component stylePropTypes keys as constants --- src/components/Image/index.js | 4 +++- src/components/Text/index.js | 4 +++- src/components/TextInput/index.js | 4 +++- src/components/View/index.js | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/Image/index.js b/src/components/Image/index.js index 6bb4222f..f0b228db 100644 --- a/src/components/Image/index.js +++ b/src/components/Image/index.js @@ -11,6 +11,8 @@ const STATUS_LOADING = 'LOADING' const STATUS_PENDING = 'PENDING' const STATUS_IDLE = 'IDLE' +const imageStyleKeys = Object.keys(ImageStylePropTypes) + const styles = { initial: { alignSelf: 'flex-start', @@ -176,7 +178,7 @@ class Image extends React.Component { const isLoaded = this.state.status === STATUS_LOADED const defaultImage = defaultSource.uri || null const displayImage = !isLoaded ? defaultImage : source.uri - const resolvedStyle = pickProps(style, Object.keys(ImageStylePropTypes)) + const resolvedStyle = pickProps(style, imageStyleKeys) const backgroundImage = displayImage ? `url("${displayImage}")` : null /** diff --git a/src/components/Text/index.js b/src/components/Text/index.js index 9d58672a..336d75a0 100644 --- a/src/components/Text/index.js +++ b/src/components/Text/index.js @@ -3,6 +3,8 @@ import CoreComponent from '../CoreComponent' import React, { PropTypes } from 'react' import TextStylePropTypes from './TextStylePropTypes' +const textStyleKeys = Object.keys(TextStylePropTypes) + const styles = { initial: { color: 'inherit', @@ -43,7 +45,7 @@ class Text extends React.Component { render() { const { children, component, numberOfLines, style, testID } = this.props - const resolvedStyle = pickProps(style, Object.keys(TextStylePropTypes)) + const resolvedStyle = pickProps(style, textStyleKeys) return (