在从 json 文件 ( https://www.rallyssimo.it/wp-json/wp/v2/categories )中获取某些类别后,我需要在我的应用程序的抽屉中动态放置一些项目
json 示例(我需要该信息)
[
{
"id": 44,
.
.
"name": "ALTRI RALLY",
.
.
},
这是抽屉:
const CustomDrawerComponent = (props) => (
<SafeAreaView style={{flex:1}}>
<View style={{height:80, backgroundColor: 'white', alignItems: 'center', justifyContent: 'center'}}>
<Image
source={{uri: 'https://www.rallyssimo.it/wp-content/uploads/2016/08/rallyssimo-logo.png'}}
style={{ height: 60, width: 180}}
/>
</View>
<ScrollView>
<DrawerItems {...props} />
</ScrollView>
</SafeAreaView>
)
const AppNavigator = createDrawerNavigator(
{
Home: DashboardStackNavigator,
},
{
contentComponent: CustomDrawerComponent
}
);
const AppContainer = createAppContainer(AppNavigator);
//Main class
export default class App extends React.Component {
render() {
return <AppContainer />;
}
}
如何将项目(我将从 JSON 中获取)放入抽屉中?