Socket
Socket
Sign inDemoInstall

react-native-lazyload-components

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-lazyload-components

lazyload for react native Image, View, ScrollView, ListView; fork from react-native-lazyload with community contributions patches and fixes merged and maintained!


Version published
Weekly downloads
4
increased by33.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

react-native-lazyload-components


A `lazyload` components suit for React Native.

Install

npm
package

Components
ComponentDescription
LazyloadScrollViewA lazyload container component based on ScrollView
LazyloadListViewA lazyload container component based on ListView
LazyloadViewBased on View component. This component`s content won`t be rendered util it scrolls into sight. It should be inside a LazyloadScrollView or LazyloadListView which has the same name prop as this component`s host prop.
LazyloadImageBased on Image component. The image content won`t be rendered util it scrolls into sight. It should be inside a LazyloadScrollView or LazyloadListView which has the same name prop as this component`s host prop.
Usage
LazyloadScrollView
  1. Using LazyloadScrollView instead of ScrollView, and specify a unique id for name prop.
  2. Layout the views or images which will be lazyloaded by using LazyloadView and LazyloadImage instead of View or Image.
  3. Specify host prop for every LazyloadView and LazyloadImage, the host prop should be same as outer LazyloadScrollView component`s name prop.
import React, {
    Component
} from 'react-native';

import {
    LazyloadScrollView,
    LazyloadView,
    LazyloadImage
} from 'react-native-lazyload';

const list = [...list data here]; // many rows

class LazyloadScrollViewExample extends Component{
    render() {
        return (
            <LazyloadScrollView
                style={styles.container}
                contentContainerStyle={styles.content}
                name="lazyload-list"
            >
                {list.map((file, i) => <View
                    key={i}
                    style={styles.view}
                >
                    <LazyloadView
                        host="lazyload-list"
                        style={styles.file}
                    >
                        <View style={styles.id}>
                            <Text style={styles.idText}>{file.id}</Text>
                        </View>
                        <View style={styles.detail}>
                            <Text style={styles.name}>{file.first_name} {file.last_name}</Text>
                            <Text><Text style={styles.title}>email: </Text><Text style={styles.email}>{file.email}</Text></Text>
                            <Text style={styles.ip}><Text style={styles.title}>last visit ip: </Text>{file.ip_address}</Text>
                        </View>
                    </LazyloadView>
                    <View style={styles.avatar}>
                        <LazyloadImage
                            host="lazyload-list"
                            style={styles.avatarImage}
                            source={file.avatar}
                        />
                    </View>
                </View>)}
            </LazyloadScrollView>
        );
    }
}

LazyloadListView

Same as ListView. But it won`t render LazyloadView and LazyloadImage inside it, util they are scrolled into sight.

Additional Methods

refresh - Force to trigger an update. Useful after nagivation pop/push where the memory may have been release.

Additional Props

Components that extend LazyloadView can accept a prop (function) to be called when the item's visibility changes.

onVisibilityChange - An optional function to be called with the new visibility, ref, and props

Example:


<LazyloadView onVisibilityChange={ this.handleItemVisibility }>
...
</LazyloadView>

...

handleItemVisibility(visibility, ref, props) {
    console.log('visibility, ref, props', visibility, ref, props);
}

Run Example

Clone this repository from Github and cd to 'Example' directory then run npm install.

Keywords

FAQs

Last updated on 04 Aug 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc