DylanVann / react-native-fast-image

🚩 FastImage, performant React Native image component.
MIT License
8.15k stars 1.5k forks source link

Tried to access a JS module before the React instance was fully set up. #1041

Open AndrewMatsiuk opened 1 month ago

AndrewMatsiuk commented 1 month ago

Hi everyone,

I've been trying to fix this issue for a week, and it's breaking my brain ((

Has anyone else encountered this problem?

Exception in native call java.lang.IllegalStateException: Tried to access a JS module before the React instance was fully set up. Calls to ReactContext#getJSModule should only happen once initialize() has been called on your native module. at com.facebook.react.bridge.ReactContext.getJSModule(ReactContext.java:180) at com.dylanvann.fastimage.FastImageViewWithUrl.onAfterUpdate(FastImageViewWithUrl.java:132) at com.dylanvann.fastimage.FastImageViewManager.onAfterUpdateTransaction(FastImageViewManager.java:181) at com.dylanvann.fastimage.FastImageViewManager.onAfterUpdateTransaction(FastImageViewManager.java:33) at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:81) at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java:181) at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:108) at com.facebook.react.fabric.mounting.SurfaceMountingManager.createViewUnsafe(SurfaceMountingManager.java:843) at com.facebook.react.fabric.mounting.SurfaceMountingManager.preallocateView(SurfaceMountingManager.java:1212) at com.facebook.react.fabric.mounting.mountitems.PreAllocateViewMountItem.execute(PreAllocateViewMountItem.java:67) at com.facebook.react.fabric.mounting.MountItemDispatcher.executeOrEnqueue(MountItemDispatcher.java:363) at com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchPreMountItems(MountItemDispatcher.java:342) at com.facebook.react.fabric.FabricUIManager$DispatchUIFrameCallback.doFrameGuarded(FabricUIManager.java:1320) at com.facebook.react.fabric.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:32) at com.facebook.react.modules.core.ReactChoreographer$1.doFrame(ReactChoreographer.java:89) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1337) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1348) at android.view.Choreographer.doCallbacks(Choreographer.java:952) at android.view.Choreographer.doFrame(Choreographer.java:878) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1322) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8177) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

Знімок екрана 2024-07-30 о 14 40 07 This problem only in android version , ios work perfect.

React Native version: 0.74.2 React version: 18.2.0 React Native Fast Image version: ^8.6.8 my build.gradle:

buildscript { ext { buildToolsVersion = "34.0.0" minSdkVersion = 23 compileSdkVersion = 34 targetSdkVersion = 34 ndkVersion = "26.1.10909125" kotlinVersion = "1.9.22" } repositories { google() mavenCentral() } dependencies { classpath("com.android.tools.build:gradle") classpath("com.facebook.react:react-native-gradle-plugin") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin") } }

apply plugin: "com.facebook.react.rootproject"

thiagomachado1998 commented 1 month ago

same error here

AndrewMatsiuk commented 1 month ago

same error here

My assumption is that before React Native version 0.73, there were MainApplication.java and MainActivity.java, but from version 0.73, everything moved to Kotlin with MainApplication.kt and MainActivity.kt.

deepanshushuklad11 commented 1 month ago

Hello , Please try @d11/react-native-fast-image ,let me know if issue persist.

AndrewMatsiuk commented 1 month ago

Hello , Please try @d11/react-native-fast-image ,let me know if issue persist.

The same, plus on the new versions of React Native, some other libraries don't work yet, so I just created a new project on an older version of React Native. I chose 0.72.11, and everything works good.

thiagomachado1998 commented 1 month ago

This problem happened to me after activating the new architecture in version 0.74.3

AndrewMatsiuk commented 1 month ago

This problem happened to me after activating the new architecture in version 0.74.3

You can check this: https://github.com/DylanVann/react-native-fast-image/pull/1032, but I think this lib doesn't work on the new building version

deepanshushuklad11 commented 1 month ago

Working on it

khushbujilka-developer commented 1 month ago

hello, I'm also facing the same issue.

deepanshushuklad11 commented 1 month ago

hello, I'm also facing the same issue.

@khushbujilka-developer Please use @d11/react-native-fast-image.