1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| import React,{Component, PropTypes } from 'react'; import { requireNativeComponent, View } from 'react-native';
var iface = { name:'MyButton', propTypes:{ text:PropTypes.string, textSize:PropTypes.number, textColor:PropTypes.number, testID:PropTypes.string, accessibilityComponentType:PropTypes.string, accessibilityLabel:PropTypes.string, accessibilityLiveRegion:PropTypes.string, renderToHardwareTextureAndroid:PropTypes.bool, importantForAccessibility:PropTypes.string, onLayout:PropTypes.bool, } };
var MyButtonView=requireNativeComponent('MyButton',iface);
class MyBtnView extends Component{ constructor(){ super(); this._onChange=this._onChange.bind(this); } _onChange(event:Event){ if(!this.props.onChangeMessage){ return; } if(event.nativeEvent.clickMe===-1){ this.props.onChangeMessage(); return; } } render(){ return <MyButtonView {...this.props} onChange={this._onChange} /> } } MyBtnView.propTypes={ onChangeMessage:React.PropTypes.func, } module.exports =MyBtnView;
|