Skip to content

Commit

Permalink
Stop expose Image.resizeMode
Browse files Browse the repository at this point in the history
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
  • Loading branch information
elicwhite authored and facebook-github-bot committed May 13, 2018
1 parent a9a612b commit 870775e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
3 changes: 0 additions & 3 deletions Libraries/Image/Image.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

'use strict';

const ImageResizeMode = require('ImageResizeMode');
const ImageStylePropTypes = require('ImageStylePropTypes');
const NativeMethodsMixin = require('NativeMethodsMixin');
const NativeModules = require('NativeModules');
Expand Down Expand Up @@ -132,8 +131,6 @@ const Image = createReactClass({
},

statics: {
resizeMode: ImageResizeMode,

getSize(
url: string,
success: (width: number, height: number) => void,
Expand Down
2 changes: 0 additions & 2 deletions Libraries/Image/Image.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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.
*
Expand Down
4 changes: 2 additions & 2 deletions RNTester/js/ImageCapInsetsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
/>
</View>
Expand All @@ -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}}
/>
</View>
Expand Down
10 changes: 5 additions & 5 deletions RNTester/js/ImageExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,15 +621,15 @@ exports.examples = [
<Text style={[styles.resizeModeText]}>Contain</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.contain}
resizeMode="contain"
source={image}
/>
</View>
<View style={styles.leftMargin}>
<Text style={[styles.resizeModeText]}>Cover</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.cover}
resizeMode="cover"
source={image}
/>
</View>
Expand All @@ -639,23 +639,23 @@ exports.examples = [
<Text style={[styles.resizeModeText]}>Stretch</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.stretch}
resizeMode="stretch"
source={image}
/>
</View>
<View style={styles.leftMargin}>
<Text style={[styles.resizeModeText]}>Repeat</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.repeat}
resizeMode="repeat"
source={image}
/>
</View>
<View style={styles.leftMargin}>
<Text style={[styles.resizeModeText]}>Center</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.center}
resizeMode="center"
source={image}
/>
</View>
Expand Down

0 comments on commit 870775e

Please sign in to comment.