Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Elements - Wrapping a touchable opacity around an input does not work in IOS

I am having a very peculiar issue with React Native Elements Text Input along with using touchable opacity.

import React, { useState } from 'react';
import { TouchableOpacity, View, Dimensions } from 'react-native';
import { Input } from 'react-native-elements';

const test = () => (
  <TouchableOpacity onPress={() => console.log('we hit here')}>
    <Input disabled>
      {children}
    </Input>
  </TouchableOpacity>
)

export default test;

So the outer rim of the input field is completely clickable, however, the center of the component, it cannot be clicked.

This works perfectly for android however.

Any ideas

like image 231
Mubeen Hussain Avatar asked Jun 03 '26 19:06

Mubeen Hussain


2 Answers

if anyone has this issue, then the you need to supply a pointerEvents to 'none' for the entire component to be clickable:

<View pointerEvents='none'>
<Input disabled>
      {children}
    </Input>
</View>
like image 169
Mubeen Hussain Avatar answered Jun 07 '26 01:06

Mubeen Hussain


Mubeen hussain answer is correct, but to be more precise it's like this

<TouchableOpacity onPress={() => console.log('we hit here')}>
  <View pointerEvents="none">
    <Input disabled>{children}</Input>
  </View>
</TouchableOpacity>
like image 44
Charitha Goonewardena Avatar answered Jun 06 '26 23:06

Charitha Goonewardena



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!