0
SplashScreenが600ミリ秒間表示され、メインスクリーンが表示されるアプリケーションを作成しようとしています。私はcomponentDidmountでsetTimeOutメソッドを使用しましたが、図のようにエラーが発生していますhere。以下に必要なコードも示します。未定義は関数ではありません:Timers - React Native
import React, { Component } from 'react';
import {Image,Dimensions, Button, Text, StyleSheet, View, TouchableOpacity} from 'react-native';
var timePassed;
class SplashScreen extends Component{
constructor(props){
super(props);
this.state={
timePassed: false
}
}
componentDidMount() {
this.setTimeout(() => {
this.setState({timePassed: true})
},600);
}
render(){
if(!this.state.timePassed){
return(
<View style={styles.container}>
<Image style={styles.logo} source={require('./Images/logo.jpg')} resizeMode="contain" />
<Text style={styles.deadlineFont}>Deadline</Text>
</View>
);
}
else{
return (
<View>
<MainScreen />
</View>
);
}
}
}
ありがとう:
はここにあなたのコードの作業例です! :) –