如何使用 nativebase 创建水平列表

How to create a horizontal list with nativebase

我正在使用 react-native 作为前端库的 nativebase 进行移动应用程序开发。我想知道如何在 nativebase

中实现水平列表项

我知道我可以使用 FlatList,但我对 nativebase 列表组件感兴趣

// import components from native base
import { List, ListItem } from "native-base";

// lets assume your you have this array
let data=[
  {
    pet: 'gsd'
  },
  {
    pet: 'husky'
  },
  {
    pet: 'rotweiler'
  }
];

// inside you render method return this component

return (
   <List horizontal={true} dataArray={data} // your array should go here
         renderRow={pet => (
             <ListItem>
                // if you want you can add a card item here, But I'm adding a simple text
                <Text> {pet.name}
                </Text>
             </ListItem>
         )}>
   </List>

)