React native 禁用本机白色屏幕

React native 禁用本机白色屏幕,react-native,React Native,我们想在应用程序崩溃时禁用经典的白色屏幕。 我们正在使用react本机异常处理程序模块,它捕获了一些错误,但不是全部错误。 当我们发现这些错误时,我们会通知自己并重新启动应用程序。 但有时会出现一些错误(例如,当服务器向应用程序提供一些它不期望的数据时),从而触发白色屏幕。 我们更希望我们的客户继续使用冻结的应用程序,或者收到他们必须重新启动应用程序的通知,而不是使用“随机”的白色屏幕。 可以吗?这里是一个演示: 你可以用 这不会处理本机错误,但会处理js级别的所有错误。您可以将此包与react

我们想在应用程序崩溃时禁用经典的白色屏幕。 我们正在使用react本机异常处理程序模块,它捕获了一些错误,但不是全部错误。 当我们发现这些错误时,我们会通知自己并重新启动应用程序。 但有时会出现一些错误(例如,当服务器向应用程序提供一些它不期望的数据时),从而触发白色屏幕。 我们更希望我们的客户继续使用冻结的应用程序,或者收到他们必须重新启动应用程序的通知,而不是使用“随机”的白色屏幕。 可以吗?

这里是一个演示:

你可以用

这不会处理本机错误,但会处理js级别的所有错误。您可以将此包与react本机异常处理程序结合使用

import * as React from 'react';
import { Button, Text, View, StyleSheet } from 'react-native';
import Constants from 'expo-constants';
import ErrorBoundary from 'react-native-error-boundary';

import ComponentWithError from './ComponentWithError'

const App = () => {
  const [isErrorComponentVisible, setIsErrorComponentVisible] = React.useState(false)

  return (
    <ErrorBoundary>
      <View style={styles.container}>
        <Text style={styles.icon}>You can use error boundary. Wrap your root app inside ErrorBoundary, then you'll be able to catch error in any of the components:

<ErrorBoundary>
  <App />
</ErrorBoundary>
import*as React from'React';
从“react native”导入{按钮、文本、视图、样式表};
从“expo常量”导入常量;
从“反应本机错误边界”导入ErrorBoundary;
从“./ComponentWithError”导入ComponentWithError
常量应用=()=>{
常量[isErrorComponentVisible,setIsErrorComponentVisible]=React.useState(false)
返回(

您可以使用错误边界。将根应用程序包装在ErrorBoundary中,然后您就可以捕获任何组件中的错误:



您使用的是哪种react本机版本?您是否检查了我的答案:stackoverflow.com/a/63458564/8079868
import * as React from 'react';
import { Button, Text, View, StyleSheet } from 'react-native';
import Constants from 'expo-constants';
import ErrorBoundary from 'react-native-error-boundary';

import ComponentWithError from './ComponentWithError'

const App = () => {
  const [isErrorComponentVisible, setIsErrorComponentVisible] = React.useState(false)

  return (
    <ErrorBoundary>
      <View style={styles.container}>
        <Text style={styles.icon}>You can use error boundary. Wrap your root app inside ErrorBoundary, then you'll be able to catch error in any of the components:

<ErrorBoundary>
  <App />
</ErrorBoundary>