Skip to content

🖼 This component provides you with an easy way to automatically set the height of the image to the provided width without using additional props

Notifications You must be signed in to change notification settings

SyysBiir/react-native-image-auto-height

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

react-native-image-auto-height

npm

This component provides you with an easy way to automatically set the height of the image to the provided width without using additional props.

Features

  • Can be used in the same way as an Image component from react-native, no extra props
  • All common props of component Image from react-native are supported
  • Auto height setting with CSS-like styles

Install

To install the module, run the following in the command line:

npm i react-native-image-auto-height --save

Usage

import React, { Component } from 'react';
import { StyleSheet } from 'react-native';
import Image from 'react-native-image-auto-height';

export default class Demo extends Component {
  render() {
    return (
      <>
        <Image
          style={styles.image}
          source={require('./image.png')}
        />

        <Image
          style={styles.image}
          source={{uri: 'http://placehold.it/350x150'}}
        />

      </>
    );
  }
}

const styles = StyleSheet.create({
    image: {
        width: 150,
        height: 'auto'
    }
});

About

🖼 This component provides you with an easy way to automatically set the height of the image to the provided width without using additional props

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published