Amartya
Amartya

Reputation: 261

Disable Copy/paste option in react native

I want to disable clipboard(copy/paste) in my react-native app

contextMenuHidden={true} didn't work for me.

Upvotes: 1

Views: 3108

Answers (2)

Amartya
Amartya

Reputation: 261

Attaching below snippet that worked for me

removeClippedSubviews={true} contextMenuHidden={true} onFocus={() => Clipboard.setString('')} onSelectionChange={() => Clipboard.setString('')}

<View removeClippedSubviews={true}>
                            <TextInput
                              contextMenuHidden={true}
                                onFocus={() => Clipboard.setString('')} 
                                onSelectionChange={() => Clipboard.setString('')}
                                style={styles.searchInput}
                                onChangeText={this.handleSearch}
                                value={search} />
                              </View>

Upvotes: 3

Uzair
Uzair

Reputation: 71

Clipboard use mostly in TextInput fields. you can refer to this post for disabling the clipboard for TextInput
Disable clipboard for TextInput in react native

Upvotes: 1

Related Questions