Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A navigator can only contain 'Screen', 'Group' or 'React.Fragment' as its direct children

<Stack.Navigator>
  {
    isLogin ? <ComponentA /> :  <ComponentB />
  }
</Stack.Navigator>


const ComponentA = () => (
 arrA.map( v => <Stack.Screen name={v.name} component={v.component} />)
)

const ComponentB = () => (
 arrB.map( v => <Stack.Screen name={v.name} component={v.component} />)
)

i want use some hooks in componentA and componentB, so i have to use them as function component, any help please?

source code

like image 677
KingAmo Avatar asked Nov 06 '22 01:11

KingAmo


1 Answers

An option could be to render the components inline:

<Stack.Navigator>
  {
    isLogin ? ComponentA({}) :  ComponentB({})
  }
</Stack.Navigator>
like image 93
Olivier Avatar answered Nov 11 '22 07:11

Olivier