Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Lazy Components not working on Expo Android: "Render Error: Cannot read property 'nativeModule' of undefined" #26174

Closed
vonmaster opened this issue Dec 30, 2023 · 1 comment · Fixed by #26464
Assignees
Labels
CLI Versioned Expo CLI -- `npx expo start` Issue accepted

Comments

@vonmaster
Copy link

vonmaster commented Dec 30, 2023

Summary

Hi all,

Using Expo 49:
I am unable to use the React.lazy functionality which allows to defer loading component’s code until it is rendered for the first time.

On Expo Web, the Lazy Component works, no problem.
But, on Expo Android, the below error is given: "Render Error: Cannot read property 'nativeModule' of undefined". I did the test on two Android devices.

I tried everything. Even in a default app, the issue occurs. Noting that I did the test on Expo 48 and the bug does not occur.

What platform(s) does this occur on?

Android

SDK Version

49

Environment

expo-env-info 1.0.5 environment info:
System:
OS: Windows 10 10.0.19045
Binaries:
Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.21 - ~\AppData\Roaming\npm\yarn.CMD
npm: 9.1.1 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: AI-231.9392.1.2311.11076708
npmPackages:
expo: ~49.0.18 => 49.0.21
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-native: 0.72.6 => 0.72.6
react-native-web: ~0.19.6 => 0.19.10
Expo Workflow: managed

Minimal reproducible example

  1. Create an app using Expo Router default template: npx create-expo-app@latest --template tabs@49
  2. Create a Component in the components folder, say:
import { Text } from './Themed';

export default function TestLazy() {
    return <Text>I'm lazy</Text>
};
  1. Add in the app / (tabs) / index.tsx file the Lazy Component :
import React from "react";
const TestLazy = React.lazy(() => import("../../components/TestLazy"));

export default function TabOneScreen() {
  return (
    <View style={styles.container}>

      <React.Suspense fallback={<Text>Loading...</Text>}>
        <TestLazy/>
      </React.Suspense>

    </View>
  );
}
  1. On Expo Web, it works, no problem. On Expo Android, the below error is given:

SmartSelect_20231230_212529_Expo Go

@vonmaster vonmaster added CLI Versioned Expo CLI -- `npx expo start` needs validation Issue needs to be validated labels Dec 30, 2023
@vonmaster vonmaster changed the title Lazy Components not working on Expo Android: "Render Error: Cannot read property 'nativeModule' of undefined" React Lazy Components not working on Expo Android: "Render Error: Cannot read property 'nativeModule' of undefined" Dec 30, 2023
@expo-bot expo-bot removed the needs validation Issue needs to be validated label Dec 30, 2023
@Kudo Kudo self-assigned this Jan 16, 2024
@expo-bot
Copy link
Collaborator

Thank you for filing this issue!
This comment acknowledges we believe this may be a bug and there’s enough information to investigate it.
However, we can’t promise any sort of timeline for resolution. We prioritize issues based on severity, breadth of impact, and alignment with our roadmap. If you’d like to help move it more quickly, you can continue to investigate it more deeply and/or you can open a pull request that fixes the cause.

Kudo added a commit that referenced this issue Jan 17, 2024
# Why

fixes #26174 
close ENG-11097

# How

on android, the `RCTNetworking` has slight difference than on ios. it's
a derived class from `NativeEventEmitter`. we should make sure the
`this` pointer is valid. this pr tries to bind the this pointer to the
correct `RCTNetworking`.

# Test Plan

testing lazy component in router-e2e and expo-go.
Kudo added a commit that referenced this issue Jan 17, 2024
# Why

fixes #26174
close ENG-11097

# How

on android, the `RCTNetworking` has slight difference than on ios. it's
a derived class from `NativeEventEmitter`. we should make sure the
`this` pointer is valid. this pr tries to bind the this pointer to the
correct `RCTNetworking`.

# Test Plan

testing lazy component in router-e2e and expo-go.

(cherry picked from commit 3b57ce1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI Versioned Expo CLI -- `npx expo start` Issue accepted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants