1

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?

gkeenley
  • 6,088
  • 8
  • 54
  • 129

1 Answers1

2

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>
Mahdi N
  • 2,128
  • 3
  • 17
  • 38
  • I posted a similar question here if you have any insight: https://stackoverflow.com/questions/61391813/react-native-can-you-conditionally-render-jsx-based-on-the-existence-of-a-strin – gkeenley Apr 23 '20 at 16:09