react-native类型检验组件prop-types

前端之家收集整理的这篇文章主要介绍了react-native类型检验组件prop-types前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
/**
* Create by bamboo on 2018-04-13
*
*/
import React,{ Component} from 'react';
import { View,Text,Button,} from 'react-native';
import PropTypes from 'prop-types'; //类型检验组件
//主页
export default class App extends Component {

static propTypes = {
onButtonPress:PropTypes. func,// 回调函数
}
onButtonPress = () =>{
console. log( ip);
}

render() {
return (
< View >
< Button
onPress= {this. onButtonPress }
title= "Learn More"
color= "#841584"
accessibilityLabel= "Learn more about this purple button"
/>
</ View >
);
}

猜你在找的React相关文章