当我按照本教程https://www.youtube.com/watch?v=5Fkx87SMoJc制作应用时。我遇到一个错误;
我也看到了super(props)上的一行;在VS代码中;
这是我的代码,因为我仍然是初学者,请通过更正我的代码来解决问题。
import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import Splash from './components/splash';
import Home from './components/index';
class Main extends Component {
constructor(props) {
super(props);
this.state = { CurrentScreen: 'Splash' };
console.log('Moving to next screen...');
setTimeout(()=>{
console.log('Done!');
this.setState({ CurrentScreen: 'Home' });
}, 3000)
}
render() {
const { CurrentScreen } = this.state
let mainScreen = CurrentScreen === 'Splash' ? <Splash /> : <Home />
return mainScreen
}
}
AppRegistry.registerComponent('App', () => Splash)
非常感谢您。