ptomasroos / react-native-tab-navigator

A tab bar that switches between scenes, written in JS for cross-platform support
MIT License
2.4k stars 416 forks source link

Error:Element type is invalid:expected a string(for built-in components) or a class/function(for composite components)but got:undefined.you likely forget to export your component from the file it's defined in,or you might have mixed up default and named imports. <TabNavigator.Item> #203

Open afckd opened 4 years ago

afckd commented 4 years ago

hi friends I am a freshman to RN. i have a issue.

Error:Element type is invalid:expected a string(for built-in components) or a class/function(for composite components)but got:undefined.you likely forget to export your component from the file it's defined in,or you might have mixed up default and named imports.

checke the render method of 'Main' This error idlocated at: in TabNavigatorItem (at main.js:32) ...

this main.js code: `import React, {Component} from 'react'; import { View, Text, Button, Image, Platform, StatusBar, StyleSheet, AppRegistry, } from 'react-native'; import {Home} from '../home/home'; import {Find} from '../find/find'; import {Mine} from '../mine/mine'; import {More} from '../more/more'; //navigtionDrawble 导航栏首页 import TabNavigator from 'react-native-tab-navigator'; //路由 // import {Navigator} from 'react-native-deprecated-custom-components'; //equals fragment export default class Main extends Component { constructor(props) { super(props); this.state = { selectedTab: 'home', }; } render() { return ( } renderSelectedIcon={() => } badgeText="1" selected={this.state.selectedTab === 'home'} onPress={() => this.setState({selectedTab: 'home'})} > {} ); } }; const styles = StyleSheet.create( { iconStyle: { width: Platform.OS === 'ios' ? 30 : 25, height: Platform.OS === 'ios' ? 30 : 25, }, }, ); ` this my package.json `{ "name": "meituan", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "react": "16.11.0", "react-native": "0.62.2", "react-native-deprecated-custom-components": "^0.1.2", "react-native-tab-navigator": "^0.3.4" }, "devDependencies": { "@babel/core": "^7.6.2", "@babel/runtime": "^7.6.2", "@react-native-community/eslint-config": "^0.0.5", "babel-jest": "^24.9.0", "eslint": "^6.5.1", "jest": "^24.9.0", "metro-react-native-babel-preset": "^0.58.0", "react-test-renderer": "16.11.0" }, "jest": { "preset": "react-native" } } ` please help me,who know this problem how fix?