ReactネイティブアプリでアンドロイドとiOSのエントリファイルを1つ使用しようとしています。反応したネイティブアプリに単一エントリファイルを使用
私はいくつかのチュートリアルに従っていると、次になってしまっています
index.js
import React, { Component } from 'react';
import { Text } from 'react-native';
export default class Main extends Component {
render() {
return (
<Text>Hello world! from both IOS and Android</Text>
);
}
}
index.ios.js
import React from 'react';
import { AppRegistry } from 'react-native';
import {Main} from './index';
AppRegistry.registerComponent('Main',() => Main);
私は次で終わりますエラー:
Element type is invalid: expected a string(for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.
importステートメントで中括弧をMainから削除すると、 '... but got:object'と表示されるので、エクスポート/インポートで何かするように感じられますが、何も動作しないようです。どんな助けもありがとう。
迅速な対応に感謝します。中括弧を削除すると、同じエラーが出ますが、「未定義」ではなく「オブジェクト」と表示されます。他に何が原因で問題が起こっているかについてのアイデアはありますか?必要に応じて他の関連コードを投稿することができます。 – Brandon
メッセージ全体を貼り付けることはできますか? –
私は実際に(約2時間後に)動作させました。私はindex.jsをindex.ios.jsとindex.android.jsと同じディレクトリに置かなくなりました。私はそれをサブディレクトリに移動してから、 './src/app'からMainをインポートするためにimport文を変更し、作業を開始しました。なぜ私は理解できないのですか? – Brandon