一个更好的React Native的列表视图--FlashList

1,621 阅读1分钟

A Better List View For React Native

<FlatList> 的一个很好的替代品,使你能够在React Native应用程序中创建一个快速和高性能的列表视图。

如何使用它

1.安装并导入。

# Yarn
$ yarn add @shopify/flash-list

# NPM
$ npm i @shopify/flash-list
import React from "react";
import { View, Text } from "react-native";
import { FlashList } from "@shopify/flash-list";

2.创建一个基本的Flash列表。

const DATA = [
  {
    title: "First Item",
  },
  {
    title: "Second Item",
  },
  {
    title: "Third Item",
  },
  {
    title: "Last Item",
  },

];
const MyList = () => {
  return (
    <FlashList
      data={DATA}
      renderItem={({ item }) => <Text>{item.title}</Text>}
      estimatedItemSize={200}
    />
  );
};

预览

A Better List View For React Native

The postA Better List View For React Native - FlashListappeared first onReactScript.