Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use TouchableNativeFeedback in React native android?

Tags:

react-native

I am getting warnings while using this component. Trying to use this component as a button. I tried require('TouchableNativeFeedback') but no use. I also tried to npm install TouchableNativeFeedback, but failed. How should it be incorporated in my react native android code?

 {
    var TouchableNativeFeedback= require('TouchableNativeFeedback');
    var Button= require('react-native-button');
    var {

      AppRegistry,
      StyleSheet,
      Text,
      View,
      Image,
      TouchableNativeFeedback,

    } = React;

    var AwesomeProject = React.createClass({
      render: function() {

        return (

          <View style={styles.container}>

            <Text style={styles.welcome}>
              My first App
            </Text>
            <Text style={styles.instructions}>
               we should get started
            </Text>
            <Text style={styles.instructions}>
                Nice!!
            </Text>
          <Image source={require('./abc.png')} style={styles.img} >
          <Text style={styles.welcome}> Inside an image! </Text>
          </Image>
          <TouchableNativeFeedback
            style={styles.img} >
              <View>
              <Text style= {styles.instructions}> 
              Button! 
              </Text>
              </View>
          </ TouchableNativeFeedback>     
          <Button style={styles.img} onClick="this.butclick">
          <View>
          <Text style={styles.instructions}>
          This is a Button 
          </Text>
          </View>
          </Button>


          </View>

        );
      }
    });

}
like image 876
Aditya Rohilla Avatar asked Oct 28 '25 05:10

Aditya Rohilla


1 Answers

It can be implement like this, see the react-native documentation for more functionality.

​ <TouchableNativeFeedback
     background={TouchableNativeFeedback.Ripple('red')}>
     <View style={styles.view}>
        <Text style={style.text}>Text Here</Text>
     </View>
  </TouchableNativeFeedback>
like image 84
Karthick Kumar Avatar answered Oct 30 '25 14:10

Karthick Kumar



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!