-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
Bug description:
On Android, variables and functions declared in injectedJavaScript are not available in code run by injectJavaScript, whereas on iOS they are. Please note that I'm using source={{ html: ... }}, not loading an external URI. I believe the behaviour on iOS is correct, that on Android is not.
To Reproduce:
I created a repo that demonstrates this issue. I was careful to create a descriptive git history, so I hope it is pretty self-explanatory: https://github.com/svdo/VarIssue. This repo contains a complete react native project that you should be able to run yourself (make sure Android emulator is running):
yarn
yarn react-native start --reset-cache
yarn react-native run-ios
yarn react-native run-androidEnvironment:
- OS: Android 9 and iOS 11
- react-native-webview version: 5.8.1
react-native info:React Native Environment Info: System: OS: macOS 10.14.4 CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz Memory: 18.87 MB / 16.00 GB Shell: 5.3 - /bin/zsh Binaries: Node: 11.14.0 - /var/folders/0d/5_t6qk7s06qf94jnypzwh6yh0000gp/T/yarn--1557086445011-0.06815149805556375/node Yarn: 1.15.2 - /var/folders/0d/5_t6qk7s06qf94jnypzwh6yh0000gp/T/yarn--1557086445011-0.06815149805556375/yarn npm: 6.9.0 - ~/.homebrew/bin/npm SDKs: iOS SDK: Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2 IDEs: Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.5 => 0.59.5
Note
- Using
injectJavaScriptto declare the variables and function, instead ofinjectedJavaScript, will cause everything to work as expected. This is demonstrated in commit svdo/VarIssue@72f3fa0. - This may or may not be related to issue When I use "inline html", can not load js file #445.
atlatosBast, laurent22, xavieramoros, petekp and tomLadderdaniel-drakontas