How to disable a View component in React Native?

Sometimes, we want to disable a View component in React Native.

In this article, we’ll look at how to disable a View component in React Native.

How to disable a View component in React Native?

To disable a View component in React Native, we can set the pointerEvents prop to 'none'.

For instance, we write:

import * as React from 'react';
import { Text, View } from 'react-native';

export default function App() {
  return (
    <View>
      <View pointerEvents="none">...</View>
    </View>
  );
}

to set the inner view’s pointerEvents prop to 'none' so that users can’t interact with the content inside.

Conclusion

To disable a View component in React Native, we can set the pointerEvents prop to 'none'.