简体   繁体   English

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

[英]React Native Element Type is Invalid. Check Render Method

I've looked around and most of these issues are a result if importing or exporting incorrectly but I've checked around my app and I'm not sure what I'm exporting/importing incorrectly. 我环顾四周,如果导入或导出不正确,大多数问题都是结果,但我已经检查了我的应用程序,我不确定我导出/导入的错误。 This is the exact error I'm getting. 这是我得到的确切错误。

React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object. React.createElement:type无效 - 期望一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:object。 You likely forgot to export your component from the file it's defined in. Check the render method of FooterTabs . 您可能忘记从其定义的文件中导出组件。检查FooterTabs的render方法。

Not sure what it means by render method. 不确定render方法的含义。 The component doesn't have a render method. 该组件没有render方法。 Anyways... 无论如何...

So FooterTabs is just me rendering some footer tabs 所以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>
    )
}

I then export it in app/components/index.js like export { default as FooterTabs } from './FooterTabs/FooterTabs' 然后我将它导出到app/components/index.js例如export { default as FooterTabs } from './FooterTabs/FooterTabs'

All other components that are imported are exported the same way. 导入的所有其他组件以相同的方式导出。

I probably just need another set of eyes here. 我可能只需要另一组眼睛。 Let me know if you need to see any other files code. 如果您需要查看任何其他文件代码,请告诉我。

Thanks! 谢谢!

I believe that navigator is undefined, causing errors when rendering the child components. 我相信navigator是未定义的,在渲染子组件时会导致错误。 In this case, navigator={navigator} needs to be changed to navigator={props.navigator} in your HomeContainer , NimbusCamera , and TrackerLibraryContainer components. 在这种情况下,需要将navigator={navigator}更改为HomeContainerNimbusCameraTrackerLibraryContainer组件中的navigator={props.navigator}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:元素类型无效,检查 React Native 中的渲染方法 - Error: Element type is invalid with Check the render method in React Native 元素类型无效:检查提供者的渲染方法(React Native) - Element type is invalid: Check render method of Providers (React Native) React-Native 错误:元素类型无效 ()。 检查`Details`的渲染方法 - React-Native Error: Element type is invalid(). Check the render method of `Details` 在 React Native App 中,我得到了错误:元素类型无效:期望一个字符串(对于内置组件)...检查 `App` 的渲染方法? - In React Native App, I Got the Error: Element type is invalid: expected a string (for built-in components) ... Check the render method of `App`? 元素类型无效:检查渲染方法 - Element type is invalid: check the render method ReactJs元素类型无效检查render方法 - ReactJs Element type is invalid Check the render method 不变违规:元素类型在 createMaterialTopTabNavigator()/MaterialTopTabView 渲染方法中无效,React Native w/React Navigation v5 - Invariant Violation: Element type is invalid in createMaterialTopTabNavigator()/MaterialTopTabView render method, React Native w/ React Navigation v5 检查`Drawer`的渲染方法。 元素类型无效错误 - Check the render method of `Drawer`. Element type is invalid Error 组件异常:元素类型无效,请检查应用程序的渲染方法 - Component Exception: Element Type is Invalid, check render Method of app 错误:元素类型无效,检查相机的渲染方法 - Error: Element type is invalid with Check the render method of Camera
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM