Categories
JavaScript Answers React Native Answers

How to disable a View component in React Native?

Spread the love

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'.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *