npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-flex-image

v0.0.4

Published

React Native component to display remote image without requirement to specify width and height but just follows the flexbox layout rule

Downloads

7

Readme

rn-flex-image

This is a React Native component to display an image. It's an alternative component for Image component. The main difference of this component from Image component is when displaying a remote image, this component still displays the image even if the layout cannot determine one or both of the width and the height of the image. In this case, Image component will display no image. For further information, see the Example section.

Example

import React from 'react';
import {SafeAreaView, StyleSheet, View, Image} from 'react-native';
import FlexImage, {DefaultImage, NoImage} from 'rn-flex-image';

export default () => {
    return <SafeAreaView style={styles.main}>
        <View style={styles.view}>
            <FlexImage
                source={source}
                defaultSource={DefaultImage}
                style={styles.image}
            />
        </View>
        <View style={[styles.view, {backgroundColor: '#ccc'}]}>
            <Image
                source={source}
                defaultSource={DefaultImage}
                style={styles.image}
            />
        </View>
    </SafeAreaView>;
}
const source = { uri: 'https://snack-web-player.s3.us-west-1.amazonaws.com/v2/47/static/media/react-native-logo.79778b9e.png' };
const styles = StyleSheet.create({
    main: {
        alignItems: 'stretch',
        alignSelf: 'stretch', 
        backgroundColor: 'red',
        flex: 1
    },
    image: {
        alignSelf: 'stretch',
        backgroundColor: 'yellow',
        flex: 1,
        resizeMode: 'contain',
        //borderWidth: 2,
        //padding: 2,
    },
    view: {
        alignItems: 'center',
        backgroundColor: 'gray',
        flex: 1,
        justifyContent: 'center',
        overflow: 'hidden',
    },
});

In the example above, if you remove alignSelf and/or flex prop from styles.image then Image component won't dsplay an image whereas FlexImage will still does. Beside that, if you change the source to a local image then Image component will dispaly the image with original size whereas the FlexImage will stretch the image. Another difference, border and padding look having more effect when using FlexImage.

Config

rn-flex-image package includes two local images. The first one is used when you don't set any source for the image and the second one is used for defaultSource prop if you don't set it. These local image can be altered via the package configuration.

When you install this package, the config file named rn-flex-image.config.js will be created automatically in the top directory of the project. If the config file doesn't exist, you must create it to avoid an error happens. In the config file you can specify the image configurations like below:

module.exports = {
    NoImage: require('./images/no-image.png'),
    DefaultImage: require('./images/default-image.png'),
};

Multiple sources

This component doesn't support multiple sources of image. If you only set multiple sources for image such as only setting srcSet prop or only setting source prop as an array, an error will happen. However, if you set srcSet and src prop then src prop will be used and srcSet prop will be ignored.