2016-03-07 18 views
10

adlı Navigator benim index.ios dosyamda kullanmak istediğiniz başka bir klasörde adında bir bileşen var. Aynı dosyada EnterName koyduğunuzda ben hiç problem olsun, ama denemek ve başka bir dosyadan içe zaman alıyorum: İki farklı EnterName bileşeni ithal yollarını ve ne işi denedimBir Bileşeni Doğal Olarak Tepki Et (Reply Native) içinde nasıl düzgün bir şekilde alabilirim?

Element type is invalid: expected a string (for built-in components 
or a class/function (for composite components) but got: undefined. 
Check the render method of `Navigator` 

: Aşağıda

import {EnterName} from './App/Components/EnterName'; var EnterName = require('./App/Components/EnterName');

(EnterName aynı dosyasında bildirildi çalışır) Navigator kullanır ve başka klasörden bileşeni EnterName kullanmayı dener bazı metindir.

render() { 
    return (
     <Navigator 
     initialRoute={{name: 'Name entry', index: 0}} 
     renderScene={(route, navigator) => 
      <EnterName 
       name={route.name} 
       onForward={() => { 
       var nextIndex = route.index + 1; 
       navigator.push({ 
        name: 'Scene ' + nextIndex, 
        index: nextIndex, 
       }); 
       }} 
       onBack={() => { 
       if (route.index > 0) { 
        navigator.pop(); 
       } 
       }} 
      /> 
     } 
     /> 
    ); 
    } 
} 

Ve, EnterName dosyasını görmek istiyorsanız, işte burada:

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

class EnterName extends Component { 
    render() { 
    return (
     <View style={styles.center}> 
     <View style={styles.flowRight}> 
      <TextInput style={styles.inputName} 
      placeholder="Enter your name" 
      textAlign="center" 
      onChangeText={(text) => this.setState({text})} 
      //value={this.state.text} 
      /> 

      <TouchableHighlight style={styles.button} 
      underlayColor='#99d9f4'> 
      <Text style={styles.buttonText}> Go </Text> 
     </TouchableHighlight> 
     </View> 
     </View> 
    ) 
    } 
} 
// The stylesheet is here, and then below it I have: 
module.export = EnterName; 

beni kodumu modülarize anlamaya yardımcı olabilir misiniz?

DÜZENLEME: module.exports'un sonunda "s" yi unuttum. İhracat varsayılan sınıf _classname gibi görünüyor Bileşen {gitmek için yoldur.

+0

ihracat varsayılan sınıf EnterName Component' –

+0

uzanır 'yapıyor deneyin kullanabilirsiniz yerine module.exports ait

import EnterName from './App/Components/EnterName 

olmalıdır ben hem o çalıştı ve 'module.export = EnterName' olmaksızın, daha sonra index.ios sınıfındaki her iki çeşitleme içeriğim var. İşe yaramadı. – AlwaysQuestioning

+0

https://github.com/react-native-simple-router-community/react-native-simple-router adresini ziyaret edebilirsiniz –

cevap

İlgili konular