Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

263
Vistas
React Native: Conditionally include tab in tab navigator based on input prop

In my React Native app I have a component, and a tab navigator within that component, like this:

class Screen extends Component {
    render() {
        return(
            <View>
                <TabNav/>
            </View>
        )
    }
}


export const TabNav = createAppContainer(createBottomTabNavigator(
    {
        A: {
            screen: A,
        },
        B: {
            screen: B
        },
        C: {
            screen: C
        }             
    }
));

I want to include C conditionally, based on a prop passed from Screen. So I tried this:

class Screen extends Component {
    render() {
        return(
            <View>
                <TabNav
                    flag={true}
                />
            </View>
        )
    }
}


export const TabNav = createAppContainer(createBottomTabNavigator(
    {
        A: {
            screen: A,
        },
        B: {
            screen: B
        },
        ...(this.props.flag ? {C: {
            screen: C,
        }} : {}),                 
    }
));

but it throws the error Cannot read property 'props' of undefined. How can I change this so that I can pass props from Screen to TabNav?

I'm using

"react-navigation": "^4.0.10",
"react-navigation-tabs": "^2.7.0",
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda