Disable Options on React-Native Text Input
JavascriptReactjsReact NativeTextinputJavascript Problem Overview
Javascript Solutions
Solution 1 - Javascript
You should add 2 attributes
selectTextOnFocus
and editable
For example:
<TextInput editable={false} selectTextOnFocus={false} />
Solution 2 - Javascript
Just give your textinput the attribute editable={false}
Solution 3 - Javascript
contextMenuHidden is to disable the user from pasting text into certain fields and to hide context menu.
Update: This hasn’t been included in a release yet. You can always see what release any commit is in by clicking on the link and looking at the tags. so I wouldn't expect it to be on a stable release until 0.55.
<TextInput contextMenuHidden={true} />
Check the commit here: Add option to hide context menu for TextInput
Solution 4 - Javascript
Set pointerEvents to none on parent View
of TextInput
to disable touch events, consider following example:
<View pointerEvents="none">
<TextInput ... />
</View>
Solution 5 - Javascript
You can use a View and use removeClippedSubviews={true} (works with Android) and use contextMenuHidden={true} (works with IOS)
<View removeClippedSubviews={true}> <TextInput contextMenuHidden={true} /> </View>
Solution 6 - Javascript
Use caretHidden={true} if you want to disable all operation like Cut Paste Copy. It will also hide your cursor as well
Solution 7 - Javascript
This trick worked for me. Here I am using NativeBase. Keep this <TextInput>
inside a <Item>
tag. Now the selection property should not work.
code sample attached below.
<Item>
<Input
value={this.props.call_state.destination}
onChangeText={text => this.props.setDestination(text)}
returnKeyType={"done"}
keyboardType={"numeric"}
/>
</Item>
You should install nativebase first and then import {Item}
from native-base in your component