美文网首页
react-native - 自定义控件

react-native - 自定义控件

作者: GA_ | 来源:发表于2017-10-13 17:14 被阅读60次
MyButton.js
import React,{
  Component
} from 'react';
import {
  Text,
  View,
} from 'react-native';

var MyButton = React.createClass({
  setNativeProps(nativeProps) {
    this._root.setNativeProps(nativeProps);
  },

  render() {
    return (
      <View ref={component => this._root = component} {...this.props}>
        <Text>{this.props.label}</Text>
      </View>
    )
  },
});

module.exports = MyButton;

使用...

    var MyButton = require('./MyButton');
    <MyButton label="Press me!" />

相关文章

网友评论

      本文标题:react-native - 自定义控件

      本文链接:https://www.haomeiwen.com/subject/voazyxtx.html