From 870775ee738e9405c6545500f9a637df9b513a02 Mon Sep 17 00:00:00 2001 From: Eli White Date: Sat, 12 May 2018 23:10:57 -0700 Subject: [PATCH] Stop expose Image.resizeMode Summary: Exposing this enum is essentially useless and at worst is a runtime cost that isn't necessary by just using the string. The value of this enum, as far as I understand it, is to enforce that only valid options are used. We can enforce this at build time with Flow. I was able to migrate our codebase with a few Find and Replace for things like ``` resizeMode={Image.resizeMode.contain} ``` Reviewed By: yungsters Differential Revision: D7983982 fbshipit-source-id: ddd7024023f8d2f01aad1fff6c8103983a1bec1a --- Libraries/Image/Image.android.js | 3 --- Libraries/Image/Image.ios.js | 2 -- RNTester/js/ImageCapInsetsExample.js | 4 ++-- RNTester/js/ImageExample.js | 10 +++++----- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index b54d624118b173..cf87d4bc782ead 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -10,7 +10,6 @@ 'use strict'; -const ImageResizeMode = require('ImageResizeMode'); const ImageStylePropTypes = require('ImageStylePropTypes'); const NativeMethodsMixin = require('NativeMethodsMixin'); const NativeModules = require('NativeModules'); @@ -132,8 +131,6 @@ const Image = createReactClass({ }, statics: { - resizeMode: ImageResizeMode, - getSize( url: string, success: (width: number, height: number) => void, diff --git a/Libraries/Image/Image.ios.js b/Libraries/Image/Image.ios.js index 4989f62d39a637..86a5525374fe40 100644 --- a/Libraries/Image/Image.ios.js +++ b/Libraries/Image/Image.ios.js @@ -10,7 +10,6 @@ 'use strict'; const ImageProps = require('ImageProps'); -const ImageResizeMode = require('ImageResizeMode'); const NativeMethodsMixin = require('NativeMethodsMixin'); const NativeModules = require('NativeModules'); const React = require('React'); @@ -36,7 +35,6 @@ const Image = createReactClass({ propTypes: ImageProps, statics: { - resizeMode: ImageResizeMode, /** * Retrieve the width and height (in pixels) of an image prior to displaying it. * diff --git a/RNTester/js/ImageCapInsetsExample.js b/RNTester/js/ImageCapInsetsExample.js index 8f84d77358cf12..76705f4d7e60d9 100644 --- a/RNTester/js/ImageCapInsetsExample.js +++ b/RNTester/js/ImageCapInsetsExample.js @@ -29,7 +29,7 @@ class ImageCapInsetsExample extends React.Component<{}> { height: 60, })} style={styles.storyBackground} - resizeMode={Image.resizeMode.stretch} + resizeMode="stretch" capInsets={{left: 0, right: 0, bottom: 0, top: 0}} /> @@ -42,7 +42,7 @@ class ImageCapInsetsExample extends React.Component<{}> { height: 60, })} style={styles.storyBackground} - resizeMode={Image.resizeMode.stretch} + resizeMode="stretch" capInsets={{left: 15, right: 15, bottom: 15, top: 15}} /> diff --git a/RNTester/js/ImageExample.js b/RNTester/js/ImageExample.js index 2801463954322d..2125e2669e7267 100644 --- a/RNTester/js/ImageExample.js +++ b/RNTester/js/ImageExample.js @@ -621,7 +621,7 @@ exports.examples = [ Contain @@ -629,7 +629,7 @@ exports.examples = [ Cover @@ -639,7 +639,7 @@ exports.examples = [ Stretch @@ -647,7 +647,7 @@ exports.examples = [ Repeat @@ -655,7 +655,7 @@ exports.examples = [ Center