you can change your components
to list of objects.
then loop inside the item by their key and value.
const components = [
{
name: "Home",
element: HomeScreen
},
{
name: "Details",
element: DetailsScreen
}
];
const renderScreen = () => {
let result = null;
if (components) {
result = components.map((item, i) => {
return <Stack.Screen name={item.name} element={item.element} />
});
}
return result;
}
return(
{renderScreen()}
)
将element => { <Stack... /> }
改为element => { return <Stack... /> }
或element => ( <Stack... /> )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.