您好,欢迎来到12图资源库!分享精神,快乐你我!我们只是素材的搬运工!!
  • 首 页
  • 当前位置:首页 > 开发 > WEB开发 >
    我在运用React Native/Redux开发中犯过的11个错误(6)
    时间:2018-01-12 21:40 来源:网络整理 作者:网络 浏览:收藏 挑错 推荐 打印

                case 2:                 

                    return 'Delete';             

                default:                 

                    return 'Submit'

             } 

        } 

                     

        render(){            

            let title = this._setTitle();              

            return(             

                <TouchableOpacity onPress={this.props.onPress}> 

                    <View style={styles.btn}> 

                        <Text style={styles.btnText}> 

                            {title}                     

                        </Text> 

                   </View

               </TouchableOpacity> 

            ) 

        } 

    Button.propTypes = { 

        id: PropTypes.number, 

        onPress: PropTypes.func.isRequired 

    export default class SomeContainer extends Component { 

        constructor(props){ 

            super(props); 

            this.state = { 

                username:null 

            } 

        } 

        _submit(){ 

            if(this.state.username){ 

                console.log(`Hello, ${this.state.username}!`); 

            } 

            else

                console.log('Please, enter username'); 

            } 

        } 

        render() { 

            return (             

                <View style={styles.container}> 

                    <Button 

                        id={0} 

                        onPress={this._submit.bind(this)}/> 

                </View

             

        } 

    (责任编辑:admin)