2017-10-17 5 views
1

現在、React Nativeでアプリケーションを開発中です。基準はIgniteでした。現時点では、非常に頻繁にアプリケーションを起動すると、わからないエラーメッセージが表示されます。たぶん誰かが私にそれが何を言っているのか、問題を解決する方法について教えてくれるでしょう。Reactネイティブエラーメッセージ:明示的にidが設定されたルートビューを追加しようとしています

Trying to add a root view with an explicit id already set. React Native uses the id field to track react tags and will overwrite this field. If that is fine, explicitly overwrite the id field to View.NO_ID before calling addRootView. 
addRootViewGroup 
    NativeViewHierarchyManager.java:504 
addRootView 
    NativeViewHierarchyManager.java:496 
addRootView 
    UIViewOperationQueue.java:572 
registerRootView 
    UIImplementation.java:129 
addRootView 
    UIManagerModule.java:211 
attachRootViewToInstance 
    ReactInstanceManager.java:897 
setupReactContext 
    ReactInstanceManager.java:855 
access$1000 
    ReactInstanceManager.java:109 
run 
    ReactInstanceManager.java:821 
handleCallback 
    Handler.java:739 
dispatchMessage 
    Handler.java:95 
dispatchMessage 
    MessageQueueThreadHandler.java:31 
loop 
    Looper.java:148 
run 
    MessageQueueThreadImpl.java:194 
run 
    Thread.java:818 

は、私は私を助けるために必要となる情報わからないんだけど、これらは、少なくとも(package.jsonから)私のプロジェクトの依存関係は次のとおりです。

"dependencies": { 
    "apisauce": "^0.14.0", 
    "babel-preset-expo": "^4.0.0", 
    "format-json": "^1.0.3", 
    "lodash": "^4.17.2", 
    "native-base": "^2.3.2", 
    "prop-types": "^15.5.10", 
    "querystringify": "0.0.4", 
    "ramda": "^0.24.1", 
    "react": "16.0.0-alpha.12", 
    "react-native": "0.48.4", 
    "react-native-animatable": "^1.2.4", 
    "react-native-config": "^0.6.0", 
    "react-native-elements": "^0.17.0", 
    "react-native-i18n": "^2.0.6", 
    "react-native-responsive-ui": "^1.1.1", 
    "react-native-simple-encryption": "^1.2.1", 
    "react-native-swiper": "^1.5.13", 
    "react-native-vector-icons": "^4.4.0", 
    "react-navigation": "^1.0.0-beta.13", 
    "react-redux": "^5.0.2", 
    "redux": "^3.6.0", 
    "redux-persist": "^4.1.0", 
    "redux-saga": "^0.15.6", 
    "reduxsauce": "0.4.1", 
    "seamless-immutable": "^7.0.1" 
}, 
"devDependencies": { 
    "@storybook/addon-storyshots": "^3.2.12", 
    "@storybook/react-native": "^3.2.12", 
    "babel-jest": "21.2.0", 
    "babel-plugin-ignite-ignore-reactotron": "^0.3.0", 
    "babel-preset-es2015": "^6.18.0", 
    "babel-preset-react-native": "3.0.2", 
    "enzyme": "^2.6.0", 
    "husky": "^0.13.1", 
    "ignite-ir-boilerplate": "^2.1.1", 
    "jest": "21.2.1", 
    "mockery": "^2.0.0", 
    "react-addons-test-utils": "~15.4.1", 
    "react-dom": "16.0.0-alpha.12", 
    "react-test-renderer": "16.0.0-alpha.12", 
    "reactotron-react-native": "^1.12.0", 
    "reactotron-redux": "^1.11.1", 
    "reactotron-redux-saga": "^1.11.1" 
}, 
+0

Hey!あなたはそれを解決しましたか? – PallavBakshi

+1

残念ながら。代わりに、Igniteなしでプロジェクトを再作成しました。 – Daniel

答えて

1

は、私は、これは場合に発生することに気づきましたコンポーネントをエクスポートした後に変数またはプロパティを宣言します。たとえば、次の場合:

export default SignInLayout extends React.Component { 
    render() { 
     <Header /> 
     <Content /> 
     <Footer /> 
    } 
} 

const styles = Stylesheet.create({ 
    red: { 
     color: red 
    } 
}); 

エラーTrying to add a root view with an explicit id already setが表示されます。

これを修正するには、コンポーネントをエクスポートする前に変数宣言を上に移動します。または、上記のコードを変更して最後にコンポーネントをエクスポートするだけで、変数の宣言を下に保つことができます。

SignInLayout extends React.Component { 
    render() { 
     <Header /> 
     <Content /> 
     <Footer /> 
    } 
} 

const styles = Stylesheet.create({ 
    red: { 
     color: red 
    } 
}); 

export default SignInLayout; 
関連する問題