Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

recyclerlistview

Package Overview
Dependencies
Maintainers
2
Versions
122
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.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
582K
increased by3.76%
Maintainers
2
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

FAQs

Package last updated on 17 Jun 2024

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc