hello everyone,
I created a bottom tab navigation page just with names, Not any component decleration but work correctly (without any data per page),
now I want to create that with own components declaration, how do I do?
import * as React from 'react';
import { Text, View, StyleSheet,TextInput } from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
const BottomTab = createBottomTabNavigator();
const BottomNavigation = ({length,obj}) => {
let screens = [];
for(let i = 0 ; i < length ; i++){
screens.push(<BottomTab.Screen name={obj.names[i]} component={obj.components[i]} />);
}
return (
<BottomTab.Navigator>
{screens}
</BottomTab.Navigator>
);
};
export default function App(){
let state = {
names: ['One','Two','Three'],
components: []
};
state.names.map((n)=>{
return state.components.push(eval('n'));
});
return (
<NavigationContainer>
<BottomNavigation length={state.names.length} obj={state} />
</NavigationContainer>
);
}
Thank.