2017-05-25 118 views
0

我在使用NavigatorIOS進行反應時遇到了一些麻煩。 如果我把我的組件在它工作得很好,但如果我嘗試從另一個組件達到它,它給了我這個錯誤的初始路徑:元素類型無效:期望string或一個類/函數,但得到:object。

元素類型無效:預期字符串(內置組件)或一個類/函數(用於複合組件),但得到:object。檢查'NavigatorIOS'的渲染方法。

這裏是代碼:

import React, { Component, PropTypes } from 'react'; 
import Dimensions from 'Dimensions'; 
import { 
    AppRegistry, 
    StyleSheet, 
    Image, 
    TouchableHighlight, 
    NavigatorIOS, 
    FadeInView, 
    Text, 
    View 
} from 'react-native'; 
import Menu from './Menu.ios'; 


class Home extends React.Component { 
    constructor(props, context) { 
    super(props, context); 
    this.onForward = this.onForward.bind(this); 
    } 

    onForward(Menu){ 
    this.props.navigator.push({ 
     component: Menu, 
     title: 'Menu', 
     navigationBarHidden: true, 
    }); 
    } 

    render() { 
    return (
     <View style={styles.container}> 
     <Image 
      style={styles.img} 
      source={require('./img/scrittaNera.png')} 
      onLoadStart={(e) => this.setState({loading: true})} 
      /> 
     <TouchableHighlight style={styles.button} onPress={this.onForward.bind(this)}> 
      <Text style={styles.buttonText}>Get Inspired</Text> 
     </TouchableHighlight> 
     </View> 
    ); 
    } 
} 

回答

0

剛剛從 onForward(Menu) {刪除菜單。

參數Menu對通過import Menu from './Menu.ios';導入的組件進行了陰影處理。

相關問題