fix(Android): Resolve crypto error with uuid usage (#1334)
* fix(Android): uuid generation issue * chore: remove redundant types/uuid dependency * refactor(Android): replace uuid function with unique instance counter
This commit is contained in:
parent
c6a39e9f1c
commit
438e29298b
|
@ -34,8 +34,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"escape-string-regexp": "2.0.0",
|
"escape-string-regexp": "2.0.0",
|
||||||
"invariant": "2.2.4",
|
"invariant": "2.2.4"
|
||||||
"uuid": "^7.0.3"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "7.4.5",
|
"@babel/core": "7.4.5",
|
||||||
|
@ -48,7 +47,6 @@
|
||||||
"@types/jest": "24.0.18",
|
"@types/jest": "24.0.18",
|
||||||
"@types/react": "16.8.8",
|
"@types/react": "16.8.8",
|
||||||
"@types/react-native": "0.60.11",
|
"@types/react-native": "0.60.11",
|
||||||
"@types/uuid": "^7.0.2",
|
|
||||||
"@typescript-eslint/eslint-plugin": "2.1.0",
|
"@typescript-eslint/eslint-plugin": "2.1.0",
|
||||||
"@typescript-eslint/parser": "2.1.0",
|
"@typescript-eslint/parser": "2.1.0",
|
||||||
"babel-eslint": "10.0.3",
|
"babel-eslint": "10.0.3",
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { v4 as uuid } from 'uuid';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Image,
|
Image,
|
||||||
|
@ -42,6 +41,11 @@ const RNCWebView = requireNativeComponent(
|
||||||
) as typeof NativeWebViewAndroid;
|
) as typeof NativeWebViewAndroid;
|
||||||
const { resolveAssetSource } = Image;
|
const { resolveAssetSource } = Image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple counter to uniquely identify WebView instances. Do not use this for anything else.
|
||||||
|
*/
|
||||||
|
let uniqueRef = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a native WebView.
|
* Renders a native WebView.
|
||||||
*/
|
*/
|
||||||
|
@ -71,15 +75,14 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
|
||||||
lastErrorEvent: null,
|
lastErrorEvent: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
uniqueRef = uuid().replace(/-/g, '');
|
|
||||||
|
|
||||||
webViewRef = React.createRef<NativeWebViewAndroid>();
|
webViewRef = React.createRef<NativeWebViewAndroid>();
|
||||||
|
|
||||||
componentDidMount = () => {
|
messagingModuleName = `WebViewMessageHandler${uniqueRef+=1}`;
|
||||||
BatchedBridge.registerCallableModule(this.getMessagingModuleName(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
getMessagingModuleName = () => `WebViewMessageHandler${this.uniqueRef}`;
|
componentDidMount = () => {
|
||||||
|
BatchedBridge.registerCallableModule(this.messagingModuleName, this);
|
||||||
|
};
|
||||||
|
|
||||||
getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
|
getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
|
||||||
|
|
||||||
|
@ -338,7 +341,7 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
|
||||||
key="webViewKey"
|
key="webViewKey"
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
messagingEnabled={typeof onMessage === 'function'}
|
messagingEnabled={typeof onMessage === 'function'}
|
||||||
messagingModuleName={this.getMessagingModuleName()}
|
messagingModuleName={this.messagingModuleName}
|
||||||
onLoadingError={this.onLoadingError}
|
onLoadingError={this.onLoadingError}
|
||||||
onLoadingFinish={this.onLoadingFinish}
|
onLoadingFinish={this.onLoadingFinish}
|
||||||
onLoadingProgress={this.onLoadingProgress}
|
onLoadingProgress={this.onLoadingProgress}
|
||||||
|
|
Loading…
Reference in New Issue