react-native - SpashScreen React Native
问题描述
因此,我尝试为我在 android 上的 react 本机应用程序创建启动画面,但我遇到了一个问题,由于我的 aws-amplify withAuthenticator,它似乎无法使用 SpashScreen.hide()。它只是不断停留在启动画面上
const AppContainer = createAppContainer(App);
class RealApp extends React.Component {
componentDidMount() {
SplashScreen.hide();
}
constructor(props) {
super(props);
}
render() {
return(
<AppContainer></AppContainer>
);
}
}
export default withAuthenticator(RealApp, {
signUpConfig,
usernameAttributes
});
有了它,它就会一直停留在 SplashScreen Image 上。然后我稍微改变了一下,像这样摆脱了“WithAuthenticator”:
const AppContainer = createAppContainer(App);
export default class RealApp extends React.Component {
componentDidMount() {
SplashScreen.hide();
}
constructor(props) {
super(props);
}
render() {
return(
<AppContainer></AppContainer>
);
}
}
从某种意义上说,它显示了 SplashScreen 然后是我的 Amplify 登录页面,但底部导航栏已经与登录页面一起呈现,因此可以切换到不同的页面,只是放大登录 UI 仍在主页上等。
解决方案
无需隐藏启动画面,只需使用 setTimeout 功能将您自己导航到另一个屏幕
componentDidMount() {
globalAny.isEditable = true;
if (Constant.isIosDevice()) {
if (CommonTask != undefined) {
CommonTask.getStatusHeight((error: any, events: any) => {
// console.log(events);
Constant.setStatusHeight({
top: events.top,
bottom: events.bottom
});
});
}
} else {
Constant.setStatusHeight({
top: StatusBar.currentHeight,
bottom: 0
});
}
// AsyncStorage.setItem("defaultUserData","0");
setTimeout(() => {
this._token();
}, 3000);
}
推荐阅读
- html - 背景图片不显示,链接正常,选择器正常,有没有我没有意识到的干扰?
- ios - iOS 如何在广播上传扩展中实现开放主机应用程序?
- arrays - 如何在 Google 工作表中为 importhtml 转置这些数据
- java - spring boot 无法连接非主数据库
- javascript - 当我击中拇指不完全在中心时,使输入范围不跳跃
- sql-server - 根据返回供应商 ID 的子查询获取前 10 个唯一供应商数据
- javascript - 在按键上应用滚动动画与在鼠标单击时相同
- sql-server - 修复迁移数据库上的孤立用户
- java - 为什么同一目录中的一个 java 类无法找到资源而其他类可以?
- angular - 设置 httpOptions 后请求停止工作