🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

recyclerlistview

Package Overview
Dependencies
Maintainers
0
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recyclerlistview

The listview that you need and deserve. It was built for performance, uses cell recycling to achieve smooth scrolling.

4.2.3
latest
Source
npm
Version published
Weekly downloads
644K
4%
Maintainers
0
Weekly downloads
 
Created

What is recyclerlistview?

RecyclerListView is a high-performance list view for React Native and web that leverages the concept of recycling cells to improve performance, especially for large data sets. It is designed to handle complex layouts and large data efficiently.

What are recyclerlistview's main functionalities?

High-Performance Scrolling

This feature allows for smooth and high-performance scrolling of large lists by recycling views that are no longer visible. The code sample demonstrates how to set up a basic RecyclerListView with a simple row renderer.

import { RecyclerListView, DataProvider, LayoutProvider } from 'recyclerlistview';

const dataProvider = new DataProvider((r1, r2) => r1 !== r2).cloneWithRows(yourDataArray);
const layoutProvider = new LayoutProvider(
  index => 0,
  (type, dim) => {
    dim.width = Dimensions.get('window').width;
    dim.height = 100;
  }
);

const rowRenderer = (type, data) => (
  <View style={{ height: 100 }}>
    <Text>{data}</Text>
  </View>
);

<RecyclerListView
  layoutProvider={layoutProvider}
  dataProvider={dataProvider}
  rowRenderer={rowRenderer}
/>;

Complex Layouts

RecyclerListView supports complex layouts by allowing different item types and sizes. The code sample shows how to define a layout provider and row renderer for different item types.

const layoutProvider = new LayoutProvider(
  index => yourDataArray[index].type,
  (type, dim) => {
    switch (type) {
      case 'type1':
        dim.width = Dimensions.get('window').width;
        dim.height = 200;
        break;
      case 'type2':
        dim.width = Dimensions.get('window').width;
        dim.height = 100;
        break;
      default:
        dim.width = 0;
        dim.height = 0;
    }
  }
);

const rowRenderer = (type, data) => {
  switch (type) {
    case 'type1':
      return <View style={{ height: 200 }}><Text>{data}</Text></View>;
    case 'type2':
      return <View style={{ height: 100 }}><Text>{data}</Text></View>;
    default:
      return null;
  }
};

<RecyclerListView
  layoutProvider={layoutProvider}
  dataProvider={dataProvider}
  rowRenderer={rowRenderer}
/>;

Dynamic Data Handling

RecyclerListView can handle dynamic data changes efficiently. The code sample demonstrates how to add new items to the list dynamically and update the data provider.

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      dataProvider: new DataProvider((r1, r2) => r1 !== r2).cloneWithRows(initialData)
    };
  }

  addItem = newItem => {
    const newData = [...this.state.dataProvider.getAllData(), newItem];
    this.setState({
      dataProvider: this.state.dataProvider.cloneWithRows(newData)
    });
  };

  render() {
    return (
      <RecyclerListView
        layoutProvider={layoutProvider}
        dataProvider={this.state.dataProvider}
        rowRenderer={rowRenderer}
      />
    );
  }
}

Other packages similar to recyclerlistview

Keywords

react-native

FAQs

Package last updated on 15 Mar 2025

Did you know?

Socket

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