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

Differences between JSX.Element, ReactNode, and ReactElement: When should each be utilized?

Currently in the process of transitioning a React application to TypeScript. Everything seems to be going smoothly, however I've encountered an issue with the return types of my render functions, specifically within my functional components. In the p ...

What are some effective ways to identify all Typescript and ESLint errors across the entire NextJS project, rather than just the currently opened files

In my current NextJS project, I am searching for a way to display errors and warnings across the entire project, rather than just within the opened files. How can I achieve this? ...

Typescript: Subscribed information mysteriously disappeared

[ Voting to avoid putting everything inside ngOnit because I need to reuse the API response and model array in multiple functions. Need a way to reuse without cluttering up ngOnInit. I could simply call subscribe repeatedly in each function to solve the p ...

How can you line up various form elements, like pickers, in a row using Material UI?

As someone new to material ui, I haven't come across a solution for my specific issue yet. While there are similar questions, none seem to address the problem of aligning different form field types. My observation is that the material ui date picker ...

Is there a way to prevent the Drop event in Angular2?

In my Angular2 application, I have created a directive for an input field. To prevent paste or Ctrl+V within the host element of this directive, I used the following code which is functioning flawlessly: @HostListener('paste', ['$event&apos ...

Why is my custom Vuelidate validator not receiving the value from the component where it is being called?

On my registration page, I implemented a custom validator to ensure that the password meets specific criteria such as being at least 12 characters long and containing at least one digit. However, I encountered an issue where the custom validator was not r ...

Steps for storing API information in localStorage:1. Retrieve the API data

My app is running sluggish due to the excessive API calls for information retrieval. To optimize performance, I want to create a unified object containing all the data that can be shared across pages and accessed from localStorage, thus enhancing the app ...

Creating React Components with TypeScript: Ensuring Typechecking in Class and Function Components

Want to ensure typechecking works when defining React Class/Function components in TypeScript? Struggling to find a comprehensive guide on how to do it correctly. I've managed to define the Props and State interfaces, but I'm unsure about how to ...

Navigating through a multidimensional array in Angular 2 / TypeScript, moving both upwards and downwards

[ {id: 1, name: "test 1", children: [ {id: 2, name: "test 1-sub", children: []} ] }] Imagine a scenario where you have a JSON array structured like the example above, with each element potenti ...

Trouble with Mui theme not being applied when inside a wrapper component

In my project using React with typescript and MUI version 5.4.2, I have been attempting to manage all styles in a single file by enclosing everything inside my App.tsx component. Problem: The custom MUI theme is not being applied throughout my application ...

What is the TypeScript's alternative to ReasonML's option type?

When using ReasonML, the option type is a variant that can be either Some('a) or None. If I were to represent the same concept in TypeScript, how would I go about it? ...

Angular 2/4: Struggling to refresh child component's view

I need assistance with updating the value of "str" in the child component's view from the parent component. I want to do this by calling the "change()" function in the child component. Here is my code: import { Component } from '@angular/core&ap ...

establishing the default value as p-multiselect

Here is the code snippet I am currently working on: export class LkBoardStatus { id : number = 0; descr : string = ''; } In the component.ts file, I have defined the following: //... lkBoardStatusList: LkBoardStatus[] = []; selectedStat ...

Issue with data-* attributes in MaterialUI React component causing TypeScript error

I am encountering an issue while attempting to assign a data-testid attribute to a Material-UI Select component. The Typescript error I am facing is as follows: Type '{ "data-testid": string; }' is not compatible with type 'HTMLAttributes&a ...

Ways to showcase corresponding information for an item contained within an array?

I'm working with a function that is designed to retrieve specific descriptions for objects nested within an array. The purpose of the function (findSettings()) is to take in an array (systemSettings) and a key (tab12) as arguments, then use a switch s ...

The real file that was brought in after indicating a module in the node_modules directory that was coded in Typescript

After creating a typescript module named moduleA, I am ready to publish this package and make it accessible from another typescript project. Currently, for testing purposes, I have installed 'moduleA' using 'npm install ../moduleA'. Th ...

Discovering the breakpoints for Angular ng-bootstrapUncover the angular ng

Utilizing ng-bootstrap in my latest project has allowed me to easily create a grid with breakpoints, like so: <div class="row"> <div class="col-sm-12 col-md-6 col-xl-4"></div> </div> Although these breakpoints are convenient, ...

Xcode is unable to locate the 'opencv2/opencv.hpp' file

I'm currently utilizing the npm module react-native-perspective-image-cropper which necessitates the installation of opencv2. Within the package's code, opencv2 is imported as follows: #import <opencv2/opencv.hpp> Despite my best efforts, ...

Methods for organizing consecutive elements within an array in Javascript/Typescript

Let's explore this collection of objects: [ { key1: "AAA", key2: "BBB" }, { key1: "BBB", key2: "CCC" }, { key1: "CCC", key2: "DD ...

How can I apply concatMap in Angular?

Can you please guide me on how to effectively utilize concatMap with getPrices() and getDetails()? export class HistoricalPricesComponent implements OnInit, OnDestroy { private unsubscribe$ = new Subject < void > (); infoTitle ...