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

Android is crashing when "onMessage" props is accessed in "react-native-webview" library #492

Closed
krishna121996 opened this issue Jan 31, 2024 · 1 comment

Comments

@krishna121996
Copy link

krishna121996 commented Jan 31, 2024

Description
Invariant Violation: Failed to call into JavaScript module method WebViewMessageHandler1.onMessage(). Module has not been registered as callable. Bridgeless Mode: false. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, HMRClient, AppRegistry, RCTEventEmitter.

Steps to reproduce
react-native@0.71.8
Install "react-native-webview": "11.26.1",
"@callstack/repack": "~3.4.0",
Run app in Android Device
Render the Html with post message.
Clicking on the button getting the Above Error.

Note: Working as expected in iOS

React Native version
0.71.8

Platforms
Android

JavaScript runtime
Hermes

Workflow
React Native (without Expo)

Architecture
None

Build type
Debug/Release mode

Device
Android simulator, Android Device

Device model
No response

Sample HTML code to Render
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> </head> <body style=" display: flex; justify-content: center; flex-direction: column; align-items: center; " > <button onclick="sendDataToReactNativeApp()" // Crash happening when we click the button style=" padding: 20; width: 200; font-size: 20; color: white; background-color: #6751ff; " > Send Data To React Native App </button> <script> const sendDataToReactNativeApp = async () => { window.ReactNativeWebView.postMessage('Data from WebView / Website'); }; </script> </body> </html>
Actual Result:
App is crashing on accessing onMessage props.

Expected Result:
App should not crash and post message should receive in omeesage event.

@jbroma
Copy link
Member

jbroma commented Feb 29, 2024

@krishna121996

I've tested this locally on android although on newest version of react-native and @callstack/repack and it's working as expected and no error is occuring. Please try upgrading first and see if that resolves your issue.

Closing this as this doesn't seem Re.Pack related and more like a react-native issue itself.

@jbroma jbroma closed this as completed Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants