Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何去除Android手机中的空白白屏来应对本地项目?_Android_React Native - Fatal编程技术网

如何去除Android手机中的空白白屏来应对本地项目?

如何去除Android手机中的空白白屏来应对本地项目?,android,react-native,Android,React Native,我是个新来的本地人 我正在用react native制作一个项目,我的android手机通过USB端口连接到笔记本电脑。当我运行项目时,我在手机上看到一个空白屏幕。我的手机是安卓9版 首先我运行了npmstart,然后我运行了npm-runandroid 我运行了adb-s设备名反转tcp:8081 tcp:8081。我手机上的屏幕仍然是空白的 这是我的App.tsx文件: import "./i18n" import React, { useState, useEffect, useRef }

我是个新来的本地人

我正在用react native制作一个项目,我的android手机通过USB端口连接到笔记本电脑。当我运行项目时,我在手机上看到一个空白屏幕。我的手机是安卓9版

首先我运行了
npmstart
,然后我运行了
npm-runandroid

我运行了adb-s设备名反转tcp:8081 tcp:8081。我手机上的屏幕仍然是空白的

这是我的App.tsx文件:

import "./i18n"
import React, { useState, useEffect, useRef } from "react"
import { YellowBox } from "react-native"
import { NavigationContainerRef } from "@react-navigation/native";
import { contains } from "ramda"
import { enableScreens } from "react-native-screens"
import { SafeAreaProvider, initialWindowSafeAreaInsets } from "react-native-safe-area-context";

import { RootNavigator, exitRoutes, setRootNavigation } from "./navigation" 
import { useBackButtonHandler } from "./navigation/use-back-button-handler"
import { RootStore, RootStoreProvider, setupRootStore } from "./models/root-store"
import * as storage from "./utils/storage"
import getActiveRouteName from "./navigation/get-active-routename"
import { ThemeProvider } from 'react-native-elements';
import * as theme from 'theme';

enableScreens()

YellowBox.ignoreWarnings([
"componentWillMount is deprecated",
"componentWillReceiveProps is deprecated",
"Require cycle:",
])

const canExit = (routeName: string) => contains(routeName, exitRoutes)

export const NAVIGATION_PERSISTENCE_KEY = "NAVIGATION_STATE"

const App: React.FunctionComponent<{}> = () => {
const navigationRef = useRef<NavigationContainerRef>()
const [rootStore, setRootStore] = useState<RootStore | undefined>(undefined)
const [initialNavigationState, setInitialNavigationState] = useState()
const [isRestoringNavigationState, setIsRestoringNavigationState] = useState(true)

setRootNavigation(navigationRef)
useBackButtonHandler(navigationRef, canExit)

    const routeNameRef = useRef()
    const onNavigationStateChange = state => {
    const previousRouteName = routeNameRef.current
    const currentRouteName = getActiveRouteName(state)

    if (previousRouteName !== currentRouteName) {
        // track screens.
        __DEV__ && console.tron.log(currentRouteName)
    }

    // Save the current route name for later comparision
    routeNameRef.current = currentRouteName

    // Clear the storage if we are navigating to auth stack
    if ( ['register', 'login', 'forgotpassword'].includes(currentRouteName) ) {
        storage.remove(NAVIGATION_PERSISTENCE_KEY);
    } else {
        // Persist navigation state to storage
        storage.save(NAVIGATION_PERSISTENCE_KEY, state)
    }
}

useEffect(() => {
    (async () => {
        setupRootStore().then(setRootStore)
    })()
}, [])

useEffect(() => {
    const restoreState = async () => {
        try {
            const state = await storage.load(NAVIGATION_PERSISTENCE_KEY)

            if (state) {
                setInitialNavigationState(state)
            }
        } finally {
            setIsRestoringNavigationState(false)
        }
    }

    if (isRestoringNavigationState) {
        restoreState()
    }
}, [isRestoringNavigationState])

if (!rootStore) {
    return null
}

return (
    <RootStoreProvider value={rootStore}>
        <SafeAreaProvider initialSafeAreaInsets={initialWindowSafeAreaInsets}>
            <ThemeProvider theme={theme}>
                <RootNavigator
                    ref={navigationRef}
                    initialState={initialNavigationState}
                    onStateChange={onNavigationStateChange}
                />
            </ThemeProvider>
        </SafeAreaProvider>
    </RootStoreProvider>
)
}

export default App
导入“/i18n”
从“React”导入React,{useState,useffect,useRef}
从“react native”导入{YellowBox}
从“@react-navigation/native”导入{NavigationContainerRef}”;
从“ramda”导入{contains}
从“react native screens”导入{enableScreens}
从“react native safe area context”导入{SafeAProvider,InitialWindowsAfearInsets};
从“/navigation”导入{RootNavigator,exitRoutes,setRootNavigation}
从“/navigation/useBackButtonHandler”导入{useBackButtonHandler}”
从“/models/root store”导入{RootStore,RootStoreProvider,setupRootStore}
从“/utils/storage”导入*作为存储
从“/navigation/get active routename”导入getActiveRouteName
从“react native elements”导入{ThemeProvider};
从“主题”导入*作为主题;
启用屏幕()
YellowBox.ignoreWarnings([
“componentWillMount已弃用”,
“componentWillReceiveProps已弃用”,
“需要周期:”,
])
const canExit=(routeName:string)=>contains(routeName,exitRoutes)
导出常量导航\u持久性\u KEY=“导航\u状态”
常量应用程序:React.FunctionComponent=()=>{
const navigationRef=useRef()
const[rootStore,setRootStore]=useState(未定义)
const[initialNavigationState,setInitialNavigationState]=useState()
常量[isRestoringNavigationState,setIsRestoringNavigationState]=useState(true)
setRootNavigation(navigationRef)
useBackButtonHandler(navigationRef、canExit)
const routeNameRef=useRef()
const onNavigationStateChange=状态=>{
const previousRouteName=routeNameRef.current
const currentRouteName=getActiveRouteName(状态)
if(先前的路由名称!==currentRouteName){
//跟踪屏幕。
__DEV__&&console.tron.log(currentRouteName)
}
//保存当前路由名称以供以后比较
routeNameRef.current=currentRouteName
//如果要导航到验证堆栈,请清除存储
如果(['register','login','forgotpassword'].includes(currentRouteName)){
删除(导航\持久性\键);
}否则{
//将导航状态持久化到存储
保存(导航\持久性\键,状态)
}
}
useffect(()=>{
(异步()=>{
setupRootStore()。然后(setRootStore)
})()
}, [])
useffect(()=>{
const restoreState=async()=>{
试一试{
const state=wait storage.load(导航\持久性\键)
如果(州){
setInitialNavigationState(状态)
}
}最后{
setIsRestoringNavigationState(false)
}
}
如果(isRestoringNavigationState){
恢复性房地产()
}
},[isRestoringNavigationState])
if(!rootStore){
返回空
}
返回(
)
}
导出默认应用程序

有人能帮忙吗?

这能回答你的问题吗?不,这回答了你的问题吗?不,那不是。