2017-07-26 89 views
0

我想使用雙棧路由器在反應本土與反應的導航包 錯誤,但是當我使用它,我得到這個錯誤StackRouter在反應母語

元素類型無效:預期字符串(內置組件)或類/函數(用於複合組件),但得到:object。 instantiateReactComponent d:\反應母語\ AwesomeProject \ node_modules \反應母語\庫\渲染\ ReactNativeStack-dev.js:1984:75 instantiateChild

我的代碼:

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

import{StackRouter} from 'react-navigation' 
export default class Activity extends Component { 

constructor(props) { 
    super(props); 

} 

render() { 
    return (
     <Text> title:adsfdsf </Text> 
    ) 
} 
} 

const AwesomeProject = StackRouter({ 
Home: {screen: Activity}, 

}, { 
initialRouteName: 'Home', 
}) 
AppRegistry.registerComponent('AwesomeProject',() => AwesomeProject); 

回答

0

你'從react-navigation導入錯誤的組件。這是StackNavigator

import { StackNavigator } from 'react-navigation' 

const AwesomeProject = StackRouter(
{ 
    Home: {screen: Activity}, 
}, 
{ 
    initialRouteName: 'Home', 
} 
) 
+0

我想使用stackrouter而不是stackNavigator @ kyle-roach –

+0

StackRouter是StackNavigator的底層API –