NavigatorIOS错误:未定义不是对象(正在评估routerArg.component)

时间:2018-09-12 09:02:48

标签: react-native

超级,超级基本的React Native安装在这里;试图向我的应用程序添加一个简单的NavigatorIOS实例。我已使用initialRoute参数填充NavigatorIOS,并将该组件的组件设置为另一个组件,但是在运行时出现标题错误。这是我所看到的图像。

enter image description here

App.js

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, {Component} from 'react';
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
import {Platform, StyleSheet, Text, View, NavigatorIOS, TabBarIOS} from 'react-native';
import {HomePage} from './app/pages/Home';

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu'
});

type Props = {};
export default class App extends Component<Props> {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.instructions}>{instructions}</Text>
          <NavigatorIOS
              intitialRoute={{
                  component: HomePage,
                  title: 'Home'
              }}/>    
      </View>
    );
  }
}

Home.js

import React, {Component} from "react";
import {View} from "react-native";

export class HomePage extends Component<{}> {

    constructor(props, context) {
        super(props, context);
    }

    _onForward = () => {
        this.props.navigator.push({
            title: 'Scene foo',
        });
    };

    render() {
        return (
          <View>
          </View>
        );
    }
}

我为什么看到这个?在macOS 10.14 Mojave上运行Xcode-10 beta和最新版本的React Native。

1 个答案:

答案 0 :(得分:1)

这是由于这里的错字

public Texture2D[] ImagesFixes;
private bool afficher;
private string text;
private Texture2D myTexture;

void OnGUI () {

    afficher = false;
    text = Tap(); //Tap is a fonction that returns the associate text of the clicked zone

    if (text == "Table") {

    //  Debug.Log (text);
        afficher = true;

        if (afficher) {

            myTexture = ImagesFixes [0];

            //Debug.Log ("je suis là");

            GUI.DrawTexture (new Rect (10, 10, 60, 60), myTexture, ScaleMode.ScaleToFit, false, 10.0f);

        }
    }

    if (text == "Boite") {

        afficher = true;

        if (afficher) {

            GUI.DrawTexture (new Rect (10, 10, 60, 60), ImagesFixes[1], ScaleMode.ScaleToFit, true, 10.0f);
        }
    }
}

using System; using System.Linq; namespace ConsoleApp1 { class Program { static void Main(string[] args) { var input = new string[] { "AB-PQ", "PQ-EF", "EF=CD", "CD-IJ", "IJ=XY", "XY-JK" }; var output = input[0] + string.Join("", input.Skip(1).Select(c => string.Join("", c.Skip(2)))); Console.WriteLine(output); Console.ReadLine(); } } } 替换为<NavigatorIOS intitialRoute ={{ // <== here component: HomePage, title: 'Home' }}/>