How to add a button in React Native?

后端 未结 9 689
暖寄归人
暖寄归人 2021-01-31 07:46

I´m confused with this whole \"no CSS\" thing, but I understand why it\'s beneficial. All I want to do is place a button in the middle of the screen but I don\'t understand how

9条回答
  •  不知归路
    2021-01-31 08:20

    Update: use built-in Button component.

    Deprecated:

    Wrap your View into TouchableHighlight for iOS and TouchableNativeFeedback for Android.

    var {
      Platform,
      TouchableHighlight,
      TouchableNativeFeedback 
    } = React;
    
    var tapSpeed = React.createClass({
      buttonClicked: function() {
        console.log('button clicked');
      },
      render: function() {
        var TouchableElement = TouchableHighlight;
        if (Platform.OS === 'android') {
         TouchableElement = TouchableNativeFeedback;
        }
        return (
        
          
            Tap me as fast as you can!
          
          
            
              Button!
            
                  
        
        );
      }
    });       
    

提交回复
热议问题