Skip to content

Commit

Permalink
feat: ✨Support all image props
Browse files Browse the repository at this point in the history
  • Loading branch information
vivaxy committed Apr 24, 2017
1 parent 9650691 commit 4088b73
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,22 @@

Initialized by [vivaxy/gt-npm-package](https://github.com/vivaxy/gt-npm-package)

## USAGE

`yarn add react-native-auto-height-image`

```js
import React, { Component } from 'react';
import AutoHeightImage from 'react-native-auto-height-image';

export default class Demo extends Component {
render() {
return (
<AutoHeightImage
width={100}
imageURL={'http://placehold.it/350x150'}
/>
);
}
}
```
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import { getImageSizeFitWidth, getImageSizeFitWidthFromCache } from './cache';

const DEFAULT_HEIGHT = 0;

const { source, resizeMode, ...autoHeightImagePropTypes } = Image.propTypes;

export default class AutoHeightImage extends Component {

static propTypes = {
...autoHeightImagePropTypes,
width: PropTypes.number.isRequired,
imageURL: PropTypes.string.isRequired,
style: Image.propTypes.style,
};

constructor(props) {
Expand Down Expand Up @@ -62,11 +64,12 @@ export default class AutoHeightImage extends Component {
}

render() {
const { imageURL, style } = this.props;
const { imageURL, style, width, ...restProps } = this.props;
return (
<Image
source={{ uri: imageURL }}
style={[this.styles.image, style]}
{...restProps}
/>
);
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"standard-version": "^4.0.0"
},
"peerDependencies": {
"react": "16.0.0-alpha.6",
"react-native": "^0.43.4"
"react": "*",
"react-native": "*"
}
}

0 comments on commit 4088b73

Please sign in to comment.