This component provides you a simple way to load a remote and local image and automatically set Image
height to the image dimension which fits the provided width.
ReactNative Image
component needs users to set both width
and height
props.
yarn add rn-auto-image-height
npm install rn-auto-image-height
Use local or remote files:
import React, { Component } from "react";
import AutoHeightImage from "rn-auto-image-height";
export default class Demo extends Component {
render() {
return (
<View>
<AutoHeightImage width={100} source={require("/path-of-image-file")} />
<AutoHeightImage
width={100}
source={{ uri: "http://placehold.it/350x150" }}
/>
</View>
);
}
}
name | type | isRequired | default | description |
---|---|---|---|---|
width |
number | ✔ | N/A | image width to fit |
source |
number or object | ✔ | N/A | local (i.e. require/import) or remote image ({uri: '...'}) |
style |
object | x | N/A |