What causes the app to crash in release mode when importing a TypeScript component, while no issues arise in debugging?

Having an issue with importing a bottom sheet written in typescript into a class component. It works correctly in debugging mode but unfortunately not in release mode. Despite checking the logcat, no readable error code or message is being printed.

Even after wrapping the typescript component inside a try-catch block, the app still crashes. Below is the typescript component:

export default function App(data: any) {
   const ref = useRef<BottomSheetRefProps>(null);

   const onPressCloseBottomSheet = useCallback(() => {
      const isActive = ref?.current?.isActive();
      if (isActive) {
         ref?.current?.scrollTo(0);
         data.data.onCloseBottomSheetParam();
      } else {
         ref?.current?.scrollTo(-(styles.windowHeight / 1.8));
      }
   }, []);

   var custom_view = data.data.custom_view;

   try {
      return (
         <GestureHandlerRootView style={styles.bottomSheetOuterWrapper}>
            <BlurView
               style={styles.blurViewStyle}
               blurRadius={1}
               blurType={'dark'}
            />
            <View style={styles.innerContainerBottomSheet}>
               <BottomSheet ref={ref}>
                  {data.data.onCloseBottomSheetParam}
                  {custom_view}                 
               </BottomSheet>
            </View>
         </GestureHandlerRootView>
      );
   } catch (e) {
      alert('BottomSheet called failed!');
      return null;
   };
}

and here is the part of class component where I import and use the bottom sheet:

...

try {
 const customview = (<ScrollView
    contentContainerStyle={styles.userEmojisScrollableView}>
    {Object.keys(all_active_users).map(e =>
       all_active_users[e].act &&
       <View style={styles.userEmojisScrollableInnerView}>
          <View style={styles.usrEmojisNameImgWrapper}>
             <FastImage
                source={all_active_users[e].profile_pic ? {
                   uri: all_active_users[e].profile_pic,
                   priority: FastImage.priority.high,
                   cache: FastImage.cacheControl.immutable,
                } : require('../assets/user.png')}
                style={styles.usrEmojiPic}
                resizeMode={FastImage.resizeMode.cover}
             />
             <Text style={styles.usrEmojiUsernameTxt}>
                {all_active_users[e].name}
             </Text>
          </View>
       </View>
    )}
 </ScrollView>);

  return (<BottomSheet data={{ custom_view: customview, onCloseBottomSheetParam: (() => this.onCloseBottomSheet()) }} />);
  } catch (e) {
     logErrors('openModalActiveUsers()', e);
     alert('openModalActiveUsers() failed!');
     return;
  };

...

Seeking suggestions on what could be causing this issue. Why does it work in debugging mode but not in release mode?

UPDATE Discovered that the app only crashes when a ScrollView is passed to the typescript function. Removing the ScrollView and passing the remaining React child components prevents the crash. The question now is why is the ScrollView causing my app to crash when used in the typescript component?

Answer №1

Finally, I have identified the issue. It turns out that Typescript mandates all nested child components within a scrollview to have a unique key. Once I added them, the error no longer occurred.

{Object.keys(all_active_users).map(e =>
    all_active_users[e].act &&
    <View key={'outer_view_' + e} style={styles.userEmojisScrollableInnerView}>
        <View key={'inner_view_' + e} style={styles.usrEmojisNameImgWrapper}>
            <FastImage
                key={'image_' + e}
                source={all_active_users[e].profile_pic ? {
                    uri: all_active_users[e].profile_pic,
                    priority: FastImage.priority.high,
                    cache: FastImage.cacheControl.immutable,
                } : require('../assets/user.png')}
                style={styles.usrEmojiPic}
                resizeMode={FastImage.resizeMode.cover}
            />
            <Text key={'name_label_' + e} style={styles.usrEmojiUsernameTxt}>
                {all_active_users[e].name}
            </Text>
        </View>
    </View>
)}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to effectively manage radio buttons in Angular 6

Here are some questions I have listed below. public QandAList = [ { question:{ id: "Q1", query:"What is the capital of France?" }, options:[ { id: "opt1", text: "Paris" }, ...

Tips for accessing nested values post-subscription in Angular with JSON data?

I have implemented a getReports method that utilizes my web API's get method to retrieve JSON formatted responses. Step1 getReports() { return this._http.get(this.url) .map((response: Response) => response.json()) ...

Unusual Type Inference in Typescript {} when Evaluating Null or Undefined

Upon upgrading from typescript 4.9.3 to 5.0.2, we encountered an error when asserting types. Can someone explain why the function "wontWorking" is not functioning correctly? I expected this function to infer v as Record<string, any>, but instead it ...

Exploring the Module System of TypeScript

I am working with a TypeScript module structured like this: let function test(){ //... } export default test; My goal is for tsc to compile it in the following way: let function test(){ //... } module.exports = test; However, upon compilation, ...

Angular 14 debug error: Incorrect base path setting

Whenever I go for a run, I have to specify a starting point such as /pis/ ng serve --serve-path /pis/ Even after following these instructions, nothing seems to load. Can anyone lend a hand with setting a starting point in the ng serve process? ...

Is the spread operator in React failing to function as anticipated?

In my current project, I encountered an issue while trying to pass a GeolocationCoordinates object to a child component using the spread operator. Strangely, in the child props, it appears as an empty object: interface HUDState { geoCoords: Geolocation ...

NextJS: Route Handler encountering Method Not Allowed (405) error when trying to redirect

Current NextJs version is 13.4.3 I have set up a route handler to capture POST requests. For more information on route handlers, please refer to the documentation at [https://nextjs.org/docs/app/building-your-application/routing/router-handlers] In this ...

Warning: The attribute 'EyeDropper' is not recognized within the context of 'Window & typeof globalThis'

Attempting to utilize "window.EyeDropper" in a project that combines vue2 and TypeScript. When writing the following code: console.log(window.EyeDropper); An error message is generated by my Vetur plugin: Property 'EyeDropper' does not exist on ...

When using Angular 4 CanActivate guard in conjunction with a service, the component may not load properly. However, by simply using Observable

When attempting to implement the CanActivate guard in Angular, I encountered an issue where it didn't work when calling a service and using return true, or even return Observable.of(true);. However, the guard did work and the component loaded success ...

Implementation of multiple angular guards causing a crash on the page

I have been attempting to implement separate guards for distinct pages. Essentially, I am checking a boolean parameter to determine if a user is logged in or not. Below are the two guard.ts codes that I am using: export class IsAuthenticatedGuard implemen ...

A more concise validation function for mandatory fields

When working on an HTML application with TypeScript, I encountered a situation where I needed to build an error message for a form that had several required fields. In my TypeScript file, I created a function called hasErrors() which checks each field and ...

The call stack size has reached its maximum limit;

Encountering an issue with the use of componentDidMount(). This method is intended to display a Tooltip by utilizing the function _getContentTooltip(). However, the problem arises as it triggers the error message common.js:444 RangeError: Maximum call st ...

The absence of the 'classes' property in the MUI component type is causing an issue in Typescript Material UI

Simply put, typescript is giving me a hard time by complaining about the missing property classes on every material-ui component. Essentially, Typescript requires the presence of the classes property in nearly all material-ui components. Here is the error ...

When attempting to open the drawer, it remains stuck and goes back to the initial route name whenever I

Currently, I am working with two types of Navigators: StackNavigator and DrawerNavigator. The version of my React Native and React Navigation is as follows: "react-native": "0.55.4", "react-navigation": "^1.0.0-beta.11", My root navigator is the StackN ...

Is there a way to view the console in a released apk?

Currently working with Ionic and in need of exporting a release APK to be able to monitor the console for any potential issues. I am aware that using 'ionic cordova run --device' allows me to view the console, but it only shows a debug APK. Is t ...

Delete a particular item from a JSON object in real-time using TypeScript/JavaScript

Upon examining the JSON data provided, it contains a node called careerLevels which includes inner child elements. input = { "careerLevelGroups": [ { "201801": 58, "201802": 74, ...

Multiple asynchronous calls in Angular 2

In my Component, there is a function that is supposed to return a value (Promise). This value requires information from two distinct sources: an API call and data from a database. The method in question looks like this: public getValue(): Promise<numb ...

React Native - state hook refreshes and causes the component to re-render, yet no changes are visible

Here is the code snippet: export default () => { const [albums, setAlbums] = useState([]); useEffect(() => { MediaLibrary.getAlbumsAsync().then((tmpAlbums) => { setAlbums(tmpAlbums); }); }, []); return ( ...

Unlocking Column Data Tooltips in Angular Datatables: A Step-by-Step Guide

I have a single datatable and was wondering how to implement tooltips for when hovering over table cells. I tried the following code snippet, which successfully populated the tooltips. However, I am interested in achieving the same functionality using Angu ...

I am encountering difficulties while attempting to import Typescript files. Upon compiling them into Javascript, I am faced with errors in the web browser, specifically the issue of "exports is not defined"

When I run TodoAppUI.js:15, I get an error saying "Uncaught ReferenceError: exports is not defined" In all my classes, I use the export keyword. For example: export class mysclass { public constructor(){} } Even though I have the proper syntax for impo ...