I'm stumbling against this error:
A navigator can only contain 'Screen', 'Group' or 'React.Fragment' as its direct children (found 'Screen' for the screen 'State').
I tried to disable prettier and eslint and make all the screens being each on one line.
If I comment the first screen, the error moves to the third screen (found 'Screen' for the screen 'StateWithSignal'
) and so on.
dependencies:
"@react-navigation/native": "^6.1.2",
"@react-navigation/native-stack": "^6.9.8",
"@react-navigation/stack": "^6.3.16",
"react-native": "0.71.0",
Here's the code.
import React, {memo} from 'react';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {RootNativeStackParamList} from './types';
import {
HomeScreen,
StateScreen,
DecoratorScreen,
CompositeScreen,
ObserverScreen,
CommandScreen,
ChainOfResponsibilityScreen,
FacadeScreen,
StateWithSignalScreen,
CompositeWithSignalScreen,
} from '../screens';
const Stack = createNativeStackNavigator<RootNativeStackParamList>();
const Navigator = () => (
<Stack.Navigator>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{title: 'Home'}}
/>
<Stack.Screen
name="State"
component={StateScreen}
options={{title: 'State'}}
/>
<Stack.Screen
name="StateWithSignal"
component={StateWithSignalScreen}
options={{title: 'StateWithSignal'}}
/>
<Stack.Screen
name="Decorator"
component={DecoratorScreen}
options={{title: 'Decorator'}}
/>
<Stack.Screen
name="Composite"
component={CompositeScreen}
options={{title: 'Composite'}}
/>
<Stack.Screen
name="CompositeWithSignal"
component={CompositeWithSignalScreen}
options={{title: 'CompositeWithSignal'}}
/>
<Stack.Screen
name="Observer"
component={ObserverScreen}
options={{title: 'Observer'}}
/>
<Stack.Screen
name="Command"
component={CommandScreen}
options={{title: 'Command'}}
/>
<Stack.Screen
name="ChainOfResponsibility"
component={ChainOfResponsibilityScreen}
options={{title: 'ChainOfResponsibility'}}
/>
<Stack.Screen
name="Facade"
component={FacadeScreen}
options={{title: 'Facade'}}
/>
</Stack.Navigator>
);
export default memo(Navigator);