Can I disable a View component in react native?

孤街醉人 提交于 2020-01-11 20:11:37

问题


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.


回答1:


You can use pointerEvents:

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

This will make the view unresponsive to touch events.




回答2:


Adding to Kerumen's answer, in some rare cases:

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

You might need to wrap it in an anonymous function:

<View pointerEvents={() => myCondition ? 'none' : 'auto'}>
  ...
</View>`


来源:https://stackoverflow.com/questions/39720039/can-i-disable-a-view-component-in-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!