如何使用Expo编译器解决React Native TypeScript应用程序中的非标准C++异常?

4nkexdtk  于 11个月前  发布在  React
关注(0)|答案(1)|浏览(55)

我希望在React Native TypeScript应用程序中解决我最近的一个问题,该应用程序使用Expo编译器运行。
以下是我的完整堆栈跟踪:

non-std C++ exception

ABI48_0_0RCTFatal
ABI48_0_0RCTConvertArrayValue
BB347F0E-F21C-3607-82E6-C8D750FDBF8C
BB347F0E-F21C-3607-82E6-C8D750FDBF8C
BB347F0E-F21C-3607-82E6-C8D750FDBF8C
_dispatch_main_queue_callback_4CF
4230C122-42E8-383B-BEEC-EE7B61F8BB61
4230C122-42E8-383B-BEEC-EE7B61F8BB61
CFRunLoopRunSpecific
GSEventRunModal
B3834960-244B-34E4-9EA0-CA4BB44EF0F3
UIApplicationMain
main
8A423F3F-B318-315E-99C7-05EE532E9C0D

字符串
下面是我的index.tsx:import { registerRootComponent } from 'expo';
从“./App”导入应用程序;
// registerRootComponent调用AppRegistry.registerComponent('main',()=> App);//它还确保了无论是在Expo Go还是在原生构建中加载应用,//环境都被适当地设置了registerRootComponent(App);
以及App.tsx:

import React, { useState } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import AccountInfo from './components/account/AccountInfo';
import ProjectInfo from './components/account/ProjectInfo';
import CustomerBasket from './components/account/CustomerBasket';
import Queries from './components/account/Queries';
import DeleteAccount from './components/account/DeleteAccount';
import { BrandVarietiesProps, StackParamList } from './types/types';

import Intro from './components/onboarding/Intro';
import PrivacyPolicy from './components/onboarding/PrivacyPolicy';
import ShopFront from './components/onboarding/ShopFront';
import VerifyAge from './components/onboarding/VerifyAge';

import ForgotPassword from './components/register/ForgotPassword';
import LoginScreen from './components/register/LoginScreen';
import NewPassword from './components/register/NewPassword';
import SignUp from './components/register/SignUp';
import VerifyEmail from './components/register/VerifyEmail';

import DeliveryAddress from './components/sales/DeliveryAddress';

import BrandVarieties from './components/shop/BrandVarieties';
import JuiceProductPage from './components/shop/JuiceProductPage';
import JuiceScreen from './components/shop/JuiceScreen';
import ProductPage from './components/shop/ProductPage';
import SearchProducts from './components/shop/SearchProducts';
import VapeScreen from './components/shop/VapeScreen';
import NonDisposableScreen from './components/shop/NonDisposableScreen';
import NonDisposableProductPage from './components/shop/NonDisposableProductPage';

import NotFoundScreen from './components/NotFoundScreen';

import ContinueShopping from './components/shop/ContinueShopping';

import SubSignUp from './components/subscriptions/SubSignUp';
import SubVapeScreen from './components/subscriptions/SubVapeScreen';
import ChooseFlavours from './components/subscriptions/ChooseFlavours';
import ManageSubscription from './components/subscriptions/ManageSubscription';

import ChangeAddress from './components/subscriptions/ChangeAddress';
import CancelMembership from './components/subscriptions/CancelMembership';
import CancelConfirm from './components/subscriptions/CancelConfirm';

import { View, Appearance, Text } from 'react-native';

import { lightStyles, darkStyles } from './styles.js';

interface Props {
  children: React.ReactNode;
}

class ErrorBoundary extends React.Component<Props> {
  state = {
    hasError: false,
    error: null,
  };

  static getDerivedStateFromError(error: Error) {
    return { hasError: true, error };
  }

  componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
    console.error('An error occurred:', error);
    console.error('Error info:', errorInfo);
  }

  render() {
    if (this.state.hasError) {
      return <View>
        <Text>Error encountered</Text>
        </View>;
    }

    return this.props.children;
  }
}

const App: React.FC = () => {
  const Stack = createStackNavigator<StackParamList>();

  const WrappedConfirmationPage: React.FC = () => (
    <View>
      {/* Placeholder content */}
    </View>
  );

  console.log("It's gucci!")
  const deviceTheme = Appearance.getColorScheme(); // 'light' or 'dark'
  const [isDarkMode, setIsDarkMode] = useState(deviceTheme === 'dark');
  const [isSubscribed, setIsSubscribed] = useState(true);

  const styles = isDarkMode ? darkStyles : lightStyles;

  return (
    <ErrorBoundary>
    <View style={{ backgroundColor: styles.background }}>
      <NavigationContainer>
        <Stack.Navigator initialRouteName="Intro">
          <Stack.Screen name="AccountInfo" component={AccountInfo} />
          <Stack.Screen name="CustomerBasket" component={CustomerBasket} />
          <Stack.Screen name="DeleteAccount" component={DeleteAccount} />
          <Stack.Screen name="ProjectInfo" component={ProjectInfo} />
          <Stack.Screen name="Queries" component={Queries} />

          <Stack.Screen name="Intro" component={Intro} />
          <Stack.Screen name="PrivacyPolicy" component={PrivacyPolicy} />
          <Stack.Screen name="ShopFront" component={ShopFront} />
          <Stack.Screen name="VerifyAge" component={VerifyAge} />

          <Stack.Screen name="ForgotPassword" component={ForgotPassword} />
          <Stack.Screen name="LoginScreen" component={LoginScreen} />
          <Stack.Screen name="NewPassword" component={NewPassword} />
          <Stack.Screen name="SignUp" component={SignUp} />
          <Stack.Screen name="VerifyEmail" component={VerifyEmail} />

          <Stack.Screen
            name="ConfirmationPage"
            component={WrappedConfirmationPage}
          />
          <Stack.Screen name="DeliveryAddress" component={DeliveryAddress} />

          <Stack.Screen name="BrandVarieties" component={BrandVarieties as any} />
          <Stack.Screen name="ContinueShopping" component={ContinueShopping} />
          <Stack.Screen name="JuiceProductPage" component={JuiceProductPage} />
          <Stack.Screen name="JuiceScreen" component={JuiceScreen} />
          <Stack.Screen name="ProductPage" component={ProductPage} />
          <Stack.Screen name="SearchProducts" component={SearchProducts as any} />
          <Stack.Screen name="VapeScreen" component={VapeScreen} />
          <Stack.Screen
            name="NonDisposableScreen"
            component={NonDisposableScreen}
          />
          <Stack.Screen
            name="NonDisposableProductPage"
            component={NonDisposableProductPage}
          />

          <Stack.Screen name="SubSignUp" component={SubSignUp} />
          <Stack.Screen name="SubVapeScreen" component={SubVapeScreen} />

          <Stack.Screen name="NotFoundScreen" component={NotFoundScreen} />
          <Stack.Screen name="ChooseFlavours" component={ChooseFlavours as any} />
          <Stack.Screen 
            name="ManageSubscription"
            component={ManageSubscription as any}
          />

          <Stack.Screen
            name="CancelMembership"
            component={CancelMembership as any}
          />
          <Stack.Screen name="ChangeAddress" component={ChangeAddress} />
          {/* <Stack.Screen name="ChangeFlavours" component={ChangeFlavours as any} /> */}
          <Stack.Screen
            name="CancelConfirm"
            component={CancelConfirm as any}

          />
        </Stack.Navigator>
      </NavigationContainer>
    </View>
    </ErrorBoundary>

 
  )
}


export default App;


我将感激一些帮助。谢谢你,
我尝试添加错误边界来防止异常,但这是不成功的

ars1skjm

ars1skjm1#

我不知道这个问题从何而来。在这个问题发生之前,我一直在正常编码。我的解决方案是在运行应用程序时清除该高速缓存。

npm run --reset-cache

字符串
我在用

  • iOS 16.5.1(20F75)
  • Expo Go v2.29.2
  • react-native:0.72.3
  • 浏览器:49.0.3

希望这个有帮助!

相关问题