Skip to content

Commit 870775e

Browse files
elicwhitefacebook-github-bot
authored andcommitted
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
1 parent a9a612b commit 870775e

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

Libraries/Image/Image.android.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
'use strict';
1212

13-
const ImageResizeMode = require('ImageResizeMode');
1413
const ImageStylePropTypes = require('ImageStylePropTypes');
1514
const NativeMethodsMixin = require('NativeMethodsMixin');
1615
const NativeModules = require('NativeModules');
@@ -132,8 +131,6 @@ const Image = createReactClass({
132131
},
133132

134133
statics: {
135-
resizeMode: ImageResizeMode,
136-
137134
getSize(
138135
url: string,
139136
success: (width: number, height: number) => void,

Libraries/Image/Image.ios.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
'use strict';
1111

1212
const ImageProps = require('ImageProps');
13-
const ImageResizeMode = require('ImageResizeMode');
1413
const NativeMethodsMixin = require('NativeMethodsMixin');
1514
const NativeModules = require('NativeModules');
1615
const React = require('React');
@@ -36,7 +35,6 @@ const Image = createReactClass({
3635
propTypes: ImageProps,
3736

3837
statics: {
39-
resizeMode: ImageResizeMode,
4038
/**
4139
* Retrieve the width and height (in pixels) of an image prior to displaying it.
4240
*

RNTester/js/ImageCapInsetsExample.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ImageCapInsetsExample extends React.Component<{}> {
2929
height: 60,
3030
})}
3131
style={styles.storyBackground}
32-
resizeMode={Image.resizeMode.stretch}
32+
resizeMode="stretch"
3333
capInsets={{left: 0, right: 0, bottom: 0, top: 0}}
3434
/>
3535
</View>
@@ -42,7 +42,7 @@ class ImageCapInsetsExample extends React.Component<{}> {
4242
height: 60,
4343
})}
4444
style={styles.storyBackground}
45-
resizeMode={Image.resizeMode.stretch}
45+
resizeMode="stretch"
4646
capInsets={{left: 15, right: 15, bottom: 15, top: 15}}
4747
/>
4848
</View>

RNTester/js/ImageExample.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,15 +621,15 @@ exports.examples = [
621621
<Text style={[styles.resizeModeText]}>Contain</Text>
622622
<Image
623623
style={styles.resizeMode}
624-
resizeMode={Image.resizeMode.contain}
624+
resizeMode="contain"
625625
source={image}
626626
/>
627627
</View>
628628
<View style={styles.leftMargin}>
629629
<Text style={[styles.resizeModeText]}>Cover</Text>
630630
<Image
631631
style={styles.resizeMode}
632-
resizeMode={Image.resizeMode.cover}
632+
resizeMode="cover"
633633
source={image}
634634
/>
635635
</View>
@@ -639,23 +639,23 @@ exports.examples = [
639639
<Text style={[styles.resizeModeText]}>Stretch</Text>
640640
<Image
641641
style={styles.resizeMode}
642-
resizeMode={Image.resizeMode.stretch}
642+
resizeMode="stretch"
643643
source={image}
644644
/>
645645
</View>
646646
<View style={styles.leftMargin}>
647647
<Text style={[styles.resizeModeText]}>Repeat</Text>
648648
<Image
649649
style={styles.resizeMode}
650-
resizeMode={Image.resizeMode.repeat}
650+
resizeMode="repeat"
651651
source={image}
652652
/>
653653
</View>
654654
<View style={styles.leftMargin}>
655655
<Text style={[styles.resizeModeText]}>Center</Text>
656656
<Image
657657
style={styles.resizeMode}
658-
resizeMode={Image.resizeMode.center}
658+
resizeMode="center"
659659
source={image}
660660
/>
661661
</View>

0 commit comments

Comments
 (0)