这是我的组件,我在文件末尾的Home组件中导出了Widget.Material.Light.TextView.ListSeparator
。该代码在React Native中工作得很好,但是我目前正在将其移植到expo,并且停止工作。我也读过它与导入有关,但是我没有那么多。
Home
我遇到此错误
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>
)
}
}
我导入错误吗?
家只是包装纸
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)
错误实际上出在播放器中,我的导入错误,但是它说我遇到了相同的错误,只是我的playPause组件。在第13行
import React, {Component} from 'react';
class Home extends Component {
render(){
return this.props.children
}
}
export default Home;
答案 0 :(得分:1)
@expo/vector-icons
不会默认导出ICON
。
@expo/vector-icons
默认使用Ionicons
。
示例
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
是 react-native-vector-icons
import Icon from 'react-native-vector-icons/dist/FontAwesome';