[英]React-Native - RangeError appears when trying to inject splash screen image
我正在尝试将启动画面图像注入到我的应用程序中,但我不断收到错误消息: RangeError:超出最大调用堆栈大小项目是 react-native-cli,这可能是问题吗?
import React, { Component } from 'react';
import { Image, View } from 'react-native';
import { inject } from 'mobx-react';
@inject("stores")
export default class SplashScreen extends Component {
constructor(props) {
super(props)
}
componentDidMount() {
const { stores, navigation } = this.props;
setTimeout (() => {
navigation.navigate("Login")
}, stores.config.SplashTime)
}
render() {
const { stores } = this.props
return (
<View style={{flex: 1}}>
<Image style={{flex: 1, width: null, height: null}} source={stores.config.SplashIMG}/>
</View>
)
}
}
将 img 链接更改为 require 并将组件修改为 DidUpdate。
componentDidUpdate() {
const { stores, navigation } = this.props;
console.log(this.props)
setTimeout (() => {
navigation.navigate("Login")
}, stores.config.SplashTime)
}
render() {
const { stores } = this.props
return (
<View style={{flex: 1}}>
<Image style={{flex: 1, width: null, height: null}} source={require('../../images/splash.jpg')}/>
</View>)
}
}```
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.