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

                                Submit                         

                        </Text> 

                    </View>  

                </TouchableOpacity> 

            </View

            ); 

        } 

    一切样式都存储在一个独自的模块中。

    包裹在TouchableOpacity中的button组件应该独自别离出来,这样才能方便我们以后重复运用它。Image组件,以后也能够重复运用,所以也应该把它别离出来。

    做了一些改动之后的样子:

    import React, { Component, PropTypes } from 'react'

    import { 

        Text, 

        TextInput, 

        View

        TouchableOpacity 

    from 'react-native'

    import styles from './styles.ios'

     

    class Avatar extends Component{ 

        constructor(props){ 

            super(props); 

        } 

        render(){         

            if(this.props.imgSrc){             

                return(                 

                    <View style={styles.avatarBlock}> 

                        <Image 

                            source={this.props.imgSrc} 

                            style={styles.avatar}/> 

                    </View

                 ) 

             } 

             return null

        } 

    Avatar.propTypes = { 

        imgSrc: PropTypes.object 

     

    class FormItem extends Component{ 

        constructor(props){ 

            super(props); 

        } 

        render(){ 

            let title = this.props.title; 

            return(  

                <View style={styles.formItem}> 

                    <Text> 

    (责任编辑:admin)