小编Vys*_*ish的帖子

反应本机ReferenceError找不到变量

已经浏览过https://facebook.github.io/react-native/docs/text.html中的文档。目前尚不清楚如何在两个类之间链接引用。我正在尝试使用标记代替它,这没有找到参考错误。

代码:

import React, {Component} from 'react';
import {
    Text,
    View,
    AppRegistry,
} from 'react-native';

class MyAppHeaderText extends Component {

    render() {
        return(
            <MyAppHeader>
                <Text style={{fontSize:20}}>
                    {this.props.children}
                </Text>
            </MyAppHeader>
        )
    }
}

class Test2 extends Component {

    constructor(props){
        super(props);

        this.state = {
            mainText: 'This is Bird',
            subText : 'Not dino'
        }
    }

    render() {
        return(
            <View>
                {/* <Text>

                    {this.state.mainText}
                    {this.state.subText}
                </Text> */}
                <MyAppHeaderText>
                    <MyAppHeader>
                        {this.state.mainText}
                        {this.state.subText}
                    </MyAppHeader>
                </MyAppHeaderText>
            </View>
        )
    }
}

export default MyAppHeaderText;

AppRegistry.registerComponent('AwesomeProject',() => Test2); …
Run Code Online (Sandbox Code Playgroud)

javascript android react-native

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

javascript ×1

react-native ×1