首页 文章

React Native Element Type无效 . 选中渲染方法

提问于
浏览
6

我环顾四周,如果导入或导出不正确,大多数问题都是结果,但我已经检查了我的应用程序,我不确定我导出/导入的错误 . 这是我得到的确切错误 .

React.createElement:type无效 - 期望一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:object . 您可能忘记从其定义的文件中导出组件 . 检查FooterTabs的render方法 .

不确定render方法的含义 . 该组件没有render方法 . 无论如何...

所以 FooterTabs 只是我渲染一些页脚选项卡

import React, { PropTypes } from 'react'
import { View, Text } from 'react-native'
import { Tabs, Tab, Icon } from 'react-native-elements'
import { HomeContainer, TrackLibraryContainer } from '~/containers'
import { NimbusCamera } from '~/components'

export default function FooterTabs (props) {
    console.log(props)
    FooterTabs.propTypes = {
        navigator: PropTypes.object.isRequired,
        dispatch: PropTypes.func.isRequired,
        activeFooterTab: PropTypes.string.isRequired,
        setFooterTab: PropTypes.func.isRequired,
    }
    return (
        <Tabs>
            <Tab
                selected={props.activeFooterTab === "home"}
                titleStyle={{fontWeight: 'bold', fontSize: 10}}
                selectedTitleStyle={{marginTop: -1, marginBottom: 6}}
                title="Home"
                onPress={(tab) => props.dispatch(props.setFooterTab("home"))}
                renderIcon={() => <Icon containerStyle={{justifyContent: 'center', alignItems: 'center', marginTop: 12}} color={'#5e6977'} type="ionicon" name='ios-home-outline' size={33} />}>
                <HomeContainer navigator={navigator}/>  
            </Tab>
            <Tab
                selected={props.activeFooterTab === "camera"}
                titleStyle={{fontWeight: 'bold', fontSize: 10}}
                selectedTitleStyle={{marginTop: -1, marginBottom: 6}}
                title="Record Preview"
                onPress={(tab) => props.dispatch(props.setFooterTab("camera"))}
                renderIcon={() => <Icon containerStyle={{justifyContent: 'center', alignItems: 'center', marginTop: 12}} color={'#5e6977'} type="ionicon" name='ios-camera-outline' size={33} />}>
                <NimbusCamera navigator={navigator}/>   
            </Tab>
            <Tab
                titleStyle={{fontWeight: 'bold', fontSize: 10}}
                selectedTitleStyle={{marginTop: -1, marginBottom: 6}}
                title="Available Streams"
                onPress={(tab) => props.dispatch(props.setFooterTab("library"))}
                renderIcon={() => <Icon containerStyle={{justifyContent: 'center', alignItems: 'center', marginTop: 12}} color={'#5e6977'} type="ionicon" name='ios-musical-notes-outline' size={33} />}>
                <TrackLibraryContainer navigator={navigator}/>  
            </Tab>
        </Tabs>
    )
}

我然后将其导出 app/components/index.js ,如 export { default as FooterTabs } from './FooterTabs/FooterTabs'

导入的所有其他组件以相同的方式导出 .

我可能只需要另一组眼睛 . 如果您需要查看任何其他文件代码,请告诉我 .

谢谢!

1 回答

  • 1

    我认为 navigator 未定义,在渲染子组件时导致错误 . 在这种情况下, navigator={navigator} 需要在 HomeContainerNimbusCameraTrackerLibraryContainer 组件中更改为 navigator={props.navigator} .

相关问题