[英]Element type is invalid: expected a string or a class/function but got: undefined
Here is my component, I exported Home
in my Home component at the end of the file.这是我的组件,我在文件末尾的 Home 组件中导出了
Home
。 The code worked just fine in React Native but I'm currently porting it to expo and it stopped working.该代码在 React Native 中运行良好,但我目前正在将其移植到 expo 并且它停止工作。 I have read also it has something to do with the imports but I don't have that many.
我也读过它与进口有关,但我没有那么多。
import React, { Component } from 'react';
import { Text, View } from 'react-native';
import Home from './src/views/containers/home'
import Header from './src/sections/components/header'
import SuggestionList from './src/videos/containers/suggestion-list'
import CategoryList from './src/videos/containers/category-list'
import Player from './src/player/containers/player'
import API from './utils/api'
export default class App extends Component<{}> {
state = {
suggestionList: [],
categoryList: []
}
async componentDidMount() {
//some code
}
render() {
return (
<Home> //Line 28
<Header/>
<Player/>
<Text>Search</Text>
<Text>Categories</Text>
<CategoryList
list={this.state.categoryList}
/>
<SuggestionList
list={this.state.suggestionList}
/>
</Home>
)
}
}
I'm getting this error我收到这个错误
Check the render method of `App`.
This error is located at:
in Home (at App.js:28)
in App (at withExpoRoot.js:20)
in RootErrorBoundary (at withExpoRoot.js:19)
in ExpoRootComponent (at renderApplication.js:35)
in RCTView (at View.js:45)
in View (at AppContainer.js:98)
in RCTView (at View.js:45)
in View (at AppContainer.js:115)
in AppContainer (at renderApplication.js:34)
Am I importing something wrong?我导入的东西有问题吗?
Home is just a wrapper家只是一个包装
import React, {Component} from 'react';
class Home extends Component {
render(){
return this.props.children
}
}
export default Home;
The error was actually in the player, where I had a bad import but then it says that I got the same error but for my playPause component.错误实际上是在播放器中,我在其中导入了错误,但随后它说我遇到了相同的错误,但对于我的 playPause 组件。 In line 13
在第 13 行
import React from 'react'
import {
TouchableHighlight,
StyleSheet,
Platform,
} from 'react-native'
import Icon from '@expo/vector-icons'
function PlayPause(props) {
return (
<TouchableHighlight //line 13
onPress={props.onPress}
style={styles.container}
underlayColor='rgba(255,255,255,.3)'
hitSlop={{
left: 5,
top: 5,
bottom: 5,
right: 5
}}
>
{
props.isPaused ? <Icon size={20} color="#98ca3f" name={
Platform.OS === 'ios' ? 'ios-play' : 'md-play'
} /> : <Icon size={20} color="#98ca3f" name={
Platform.OS === 'ios' ? 'ios-pause' : 'md-pause'} />
}
</TouchableHighlight>
)
}
export default PlayPause
@expo/vector-icons
does not default export ICON
. @expo/vector-icons
不默认导出ICON
。
@expo/vector-icons
uses Ionicons
by default. @expo/vector-icons
默认使用Ionicons
。
about @expo/vector-icons
关于
@expo/vector-icons
example例子
import { Ionicons } from '@expo/vector-icons';
...
{
props.isPaused ? <Ionicons size={20} color="#98ca3f" name={
Platform.OS === 'ios' ? 'ios-play' : 'md-play'
} /> : <Ionicons size={20} color="#98ca3f" name={
Platform.OS === 'ios' ? 'ios-pause' : 'md-pause'} />
}
ICON
is the prop of react-native-vector-icons
ICON
是react-native-vector-icons
的支柱
import Icon from 'react-native-vector-icons/dist/FontAwesome';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.