我将react-native的版本更新为0.59,现在出现红色屏幕,显示以下消息:
不变违规:元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义。您可能忘记了从定义文件中导出组件,或者可能混淆了默认导入和命名导入。
在更新之前可以正常工作。我需要更改代码的内容:
import { Platform, View, StatusBar } from 'react-native';
//import { Constants, Notifications } from 'expo-constants';
import Constants from 'expo-constants';
import { handleNotification } from './helpers/notifications';
import CYPTUStyles from './config/styles';
import { connect, getState } from './store';
import * as NavigationService from './navigators/navigationService';
import CreateRootSwitchNavigator from './navigators/AppNavigator';
const LatoRegular = require('./assets/fonts/Lato-Regular.ttf');
const icomoon = require('../resources/fonts/icomoon.ttf');
const HandycheeraRegular = require('./assets/fonts/Handycheera-Regular.otf');
const SpaceMonoRegular = require('./assets/fonts/SpaceMono-Regular.ttf');
class Root extends React.Component {
constructor(props) {
super(props);
this.state = {
fontsAreLoaded: false
};
}
componentWillMount() {
this.props.actions.recoverToken();
this.props.actions.getAccountDetails();
this.loadFonts();
console.disableYellowBox = true;
//this.notificationSubscription = Notifications.addListener(handleNotification);
}
componentWillUnmount() {
// if (this.notificationSubscription) {
// this.notificationSubscription.remove();
// }
}
async loadFonts() {
await Expo.Font.loadAsync({
Lato_Regular: LatoRegular,
icomoon: icomoon,
Handycheera_Regular: HandycheeraRegular,
SpaceMono_Regular: SpaceMonoRegular
});
this.setState({ fontsAreLoaded: true });
}
render() {
if (!this.state.fontsAreLoaded || !this.props.recoverTokenDone) {
return <Expo.AppLoading />;
}
const RootNavigator = CreateRootSwitchNavigator(getState().isLoggedIn);
return (
<View style={{ flex: 1 }}>
{Platform.OS === 'ios' ? (
<View>
<StatusBar barStyle="light-content" />
<View
style={{
backgroundColor: CYPTUStyles.MadisonDark,
height: Constants.statusBarHeight
}}
/>
</View>
) : null}
<RootNavigator
ref={(navigatorRef) => {
NavigationService.setNavigator(navigatorRef);
}}
/>
</View>
);
}
}
export default connect(state => ({
recoverTokenDone: state.recoverTokenDone
}))(Root);
答案 0 :(得分:0)
也请在您的AppNavigator.js文件中显示