I have a nested top navigator that dynamically grows as I add days to a routine.
Starting from zero, after you add the first day the screen isn’t rendered, only after adding the second screen both the first and second screen are rendered fine.
I tested just putting a Text view in the Day Scream component and trying to add one day but still nothing renders.
Been looking at it for a few hours and can’t find what’s wrong.
Where I add days to the Tab Navigator
<TouchableOpacity style={style.closeButton} onPress={() => {
const newObj = { ...splitDays, [dayName]: [] }
setSplitDays(newObj);
setDays([...days, dayName.toString()]);
setdayName("");
setaddDayModal(false);
}}>
<Tab.Navigator
tabBarOptions={{
activeTintColor: '#000000',
indicatorStyle: {
backgroundColor: '#5D4DE4',
},
tabBarLabelStyle: {
fontFamily: 'nunito'
},
}}
screenOptions={{
tabBarScrollEnabled: true,
}}
>
{
days.length != 0 ?
<>
{
days.map((day) => (
// maps days to screens in the tab navigator
// day is just the title and dayData is an array of exercies taken from split days
<Tab.Screen name={day} key={day} component={DayScreen} initialParams={{ day: day, dayData: splitDays[day], setstaged: setstaged }} />
))
}
</>
:
<Tab.Screen
name="Empty"
component={Text} />
}
</Tab.Navigator>