2017-02-17 4 views
1

文字通り、初期化コードをindex.android.js/index.ios.jsからapp/index.jsに移動するだけです。私はそれをエクスポートし、それをindex.android.jsまたはindex.ios.jsに戻します。糸でネイティブビルドエラーに反応しますか?

次にエラーが発生します。私は、NPMを使用する場合

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object

は、この問題を持っていませんでした。私のパッケージャに何かを保存するときはいつでも、糸の構築プロセスは異なるかもしれないと言われます。

Bundling 'index.android.js'しかしiOSについては何も言いません。この

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

export default class Snapp extends Component { 
    render() { 
    return (
     <View style={styles.container}> 
     <Text style={styles.welcome}> 
      Welcome to React Native! 
     </Text> 
     </View> 
    ); 
    } 
} 

そして、私のindex.android.jsindex.ios.jsファイルのような

app/index.jsルックスはこの

import Snapp from './app' 
import { AppRegistry } from 'react-native'; 

AppRegistry.registerComponent('Snapp',() => Snapp); 

任意の考えのように見えますか?

+0

'ネイティブ反応すると、あなたは、パッケージャを再起動しました糸のインストールの間に開始 - - リセットキャッシュ? – wmcbain

+0

私のプロジェクトで 'rm yarn.lock && rm -rf node_module && npm install'を実行し、' react-native start -reset-cache'を実行してもエラーが発生しました。 – maxwellgover

+0

パッケージャが停止していることを確認し、 'rm -rf ios/build ios/DerivedData rm -rf node_modules'も試してください。 Xcodeプロジェクトを開いてクリーンアップします(cmd + shift + K)。モジュールを再インストールし、packagerをリセットキャッシュで再起動してから実行してください。 – wmcbain

答えて

1

コンポーネントを同じJSに登録してみてください。

アプリ/ index.js

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

export default class Snapp extends Component { 
    render() { 
    return (
     <View style={styles.container}> 
     <Text style={styles.welcome}> 
      Welcome to React Native! 
     </Text> 
     </View> 
    ); 
    } 
} 
AppRegistry.registerComponent('Snapp',() => Snapp); 

index.ios.js/index.android.js

require('./app/'); 
+0

これを試してみましたが、今は 'BatchedBridgeを取得できませんでした。あなたのバンドルが正しくパッケージ化されていることを確認してください。私が元のコードに戻ってリセットすると、エラーは消えてしまいます。 – maxwellgover

+0

@maxwelアプリの後に「/」が付いていることを確認してください。 require( './ app /'); – Damathryx

+0

require( './app');そのエラーになるでしょう – Damathryx

関連する問題