0

NavigatorIOS コンポーネントをレンダリングしようとするとエラーが発生します。単純なビューとテキストで試してみると、うまくいきました。しかし、NavigatorIOS の場合、エラーが発生します。

import React, {Component} from 'react';

const LandingPage = require('./layouts/landing_page/LandingPage');
const I18n = require('react-native-i18n');
const AsyncStorageHelper = require('./ios_commons/helper/AsyncStorageHelper');
const moment = require('moment');
var TranslationProperty = require('./properties/TranslationProperties.json');

import {StyleSheet, StatusBar, NavigatorIOS} from 'react-native';

export default class App extends Component<{}> {
    constructor(props) {
        super(props);
        this.state = {};
        I18n.fallbacks = true;
        I18n.translations = require('./ios_commons/Strings');
        // Text.defaultProps.allowFontScaling = false;
        StatusBar.setBarStyle('light-content', true);
        this.loadAppSpecificLanguage();
    }

    loadAppSpecificLanguage = () => {
        AsyncStorageHelper.getAppSpecificLanguage()
            .then(item => {
                if (item !== null) {
                    console.log('Found app specific locale ' + item);
                    let userDefinedLocale = JSON.parse(item).code;
                    I18n.locale = userDefinedLocale;
                    moment.locale(userDefinedLocale);
                } else {
                    console.log('App specific language property not found');
                    let defaultLocale = TranslationProperty.slice()[0];
                    if (defaultLocale === null || defaultLocale === undefined) {
                        console.log(
                            'LOCALIZATION WARNING: Couldn\'t find default locale. Setting to locale \'en\'',
                        );
                        I18n.locale = 'en';
                        moment.locale('en');
                    } else {
                        console.log('Setting default locale ' + defaultLocale.code);
                        moment.locale(defaultLocale.code);
                        AsyncStorageHelper.saveAppSpecificLanguage(defaultLocale);
                    }
                }
            })
            .catch(error => {
                console.log('Failed to obtain app specific language ' + error);
            });
    };

    render() {
        return (
            <NavigatorIOS
                style={styles.navigationContainer}
                ref="nav"
                initialRoute={{
                    title: 'LandingPage',
                    component: LandingPage,
                }}
                navigationBarHidden={true}
            />
        );
    }
}

const styles = StyleSheet.create({
    navigationContainer: {
        flex: 1,
    },
});

私が見ているエラーは次のとおりです。

未処理の JS 例外: エラー: 要素の型が無効です: 文字列 (組み込みコンポーネントの場合) またはクラス/関数 (複合コンポーネントの場合) が必要ですが、取得: 未定義です。コンポーネントが定義されているファイルからコンポーネントをエクスポートするのを忘れている可能性があります。または、デフォルトのインポートと名前付きインポートを混同している可能性があります。

のレンダリング方法を確認してくださいApp

このエラーは次の場所にあります: アプリ内 (renderApplication.js:45) RCTView (AppContainer.js:109) 内 RCTView (AppContainer.js:135) 内 AppContainer (renderApplication.js:39)

これは何が原因ですか?これを修正する方法は?

4

0 に答える 0