Search code examples
javascriptfacebookreactjsreact-nativereactjs-native

Can I disable a View component in react native?


My app screen has a View component with few Text Inputs. I cannot disable text inputs. Is there a way that I can disable complete View?

P.S.: By Disabling a View component I mean that the component renders but becomes unresponsive of any action.


Solution

  • You can use pointerEvents:

    <View pointerEvents="none">
      ...
    </View>
    

    This will make the view unresponsive to touch events.

    You can use something like

    <View pointerEvents={myCondition ? 'none' : 'auto'}>