Skip to content

Commit

Permalink
sharing: Stop passing width and height props to Image component.
Browse files Browse the repository at this point in the history
As of RN v0.62.2, which we're on currently, we've technically been
allowed to choose between setting `width` and `height` as their own
props, or putting them in the `style` prop. Here's the relevant bit
of the type definition:

```js
  /**
   * See https://facebook.github.io/react-native/docs/image.html#style
   */
  style?: ?ImageStyleProp,

  // Can be set via props or style, for now
  height?: ?DimensionValue,
  width?: ?DimensionValue,
```

But the `width` and `height` props aren't in the documentation [1];
it seems that the most proper place for them is in the `style` prop.
And when we upgrade to RN v0.63, which we hope to do soon, we'll no
longer be allowed to choose; using the `style` prop will be the only
option.

We've already been passing `width` and `height` in the `style` prop,
so just fall back to doing that by itself.

[1] https://reactnative.dev/docs/0.62/image
  • Loading branch information
chrisbobbe committed Dec 4, 2020
1 parent f22a654 commit c4441b0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
7 changes: 1 addition & 6 deletions src/sharing/ShareToPm.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,7 @@ class ShareToPm extends React.Component<Props, State> {
let sharePreview = null;
if (sharedData.type === 'image') {
sharePreview = (
<Image
source={{ uri: sharedData.sharedImageUrl }}
width={200}
height={200}
style={styles.imagePreview}
/>
<Image source={{ uri: sharedData.sharedImageUrl }} style={styles.imagePreview} />
);
}

Expand Down
7 changes: 1 addition & 6 deletions src/sharing/ShareToStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,7 @@ class ShareToStream extends React.Component<Props, State> {
<ScrollView style={styles.wrapper} keyboardShouldPersistTaps="always">
<View style={styles.container}>
{sharedData.type === 'image' && (
<Image
source={{ uri: sharedData.sharedImageUrl }}
width={200}
height={200}
style={styles.imagePreview}
/>
<Image source={{ uri: sharedData.sharedImageUrl }} style={styles.imagePreview} />
)}
<AnimatedScaleComponent visible={isStreamFocused}>
<StreamAutocomplete filter={stream} onAutocomplete={this.handleStreamAutoComplete} />
Expand Down

0 comments on commit c4441b0

Please sign in to comment.