如何使用nativebase创建水平列表

问题描述 投票:0回答:1

我正在作为本地库我的前端库在react-native中进行移动应用程序开发。我想知道如何在nativebase中实现水平列表项

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

react-native listview native-base
1个回答
0
投票
// 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>

)
© www.soinside.com 2019 - 2024. All rights reserved.