gkeenley
gkeenley

Reputation: 7398

React Native: is it possible to make a component and all its children disappear?

In my React Native app I have a <View> with several other elements nested inside it. Normally if I want to make a component disappear, I make its height go to 0, make its opacity 0, etc. But I want a universal way to apply a style to the <View> and have it and all its child components disappear.

Does anyone know how I can approach this?

Upvotes: 1

Views: 368

Answers (1)

Mahdi N
Mahdi N

Reputation: 2178

You can use condition inside curly braces in jsx to show or hide component

<View>
  {
    condition && (
      <View> // <- View and its children will show only if condition is true
        //Children components
      </View>
    )
  }
</View>

Upvotes: 2

Related Questions