Browse Source

Removed useless state and cleaned componentWillMount

Thibault Malbranche 5 years ago
parent
commit
aca9c2e31f
2 changed files with 2 additions and 16 deletions
  1. 1
    9
      js/WebView.android.js
  2. 1
    7
      js/WebView.ios.js

+ 1
- 9
js/WebView.android.js View File

54
 type State = {|
54
 type State = {|
55
   viewState: WebViewState,
55
   viewState: WebViewState,
56
   lastErrorEvent: ?WebViewError,
56
   lastErrorEvent: ?WebViewError,
57
-  startInLoadingState: boolean,
58
 |};
57
 |};
59
 
58
 
60
 /**
59
 /**
71
   };
70
   };
72
 
71
 
73
   state = {
72
   state = {
74
-    viewState: WebViewState.IDLE,
73
+    viewState: this.props.startInLoadingState ? WebViewState.LOADING : WebViewState.IDLE,
75
     lastErrorEvent: null,
74
     lastErrorEvent: null,
76
-    startInLoadingState: true,
77
   };
75
   };
78
 
76
 
79
   webViewRef = React.createRef();
77
   webViewRef = React.createRef();
80
 
78
 
81
-  UNSAFE_componentWillMount() {
82
-    if (this.props.startInLoadingState) {
83
-      this.setState({ viewState: WebViewState.LOADING });
84
-    }
85
-  }
86
-
87
   render() {
79
   render() {
88
     let otherView = null;
80
     let otherView = null;
89
 
81
 

+ 1
- 7
js/WebView.ios.js View File

76
 type State = {|
76
 type State = {|
77
   viewState: WebViewState,
77
   viewState: WebViewState,
78
   lastErrorEvent: ?WebViewError,
78
   lastErrorEvent: ?WebViewError,
79
-  startInLoadingState: boolean,
80
 |};
79
 |};
81
 
80
 
82
 const DataDetectorTypes = [
81
 const DataDetectorTypes = [
137
   };
136
   };
138
 
137
 
139
   state = {
138
   state = {
140
-    viewState: WebViewState.IDLE,
139
+    viewState: this.props.startInLoadingState ? WebViewState.LOADING : WebViewState.IDLE,
141
     lastErrorEvent: null,
140
     lastErrorEvent: null,
142
-    startInLoadingState: true,
143
   };
141
   };
144
 
142
 
145
   webViewRef = React.createRef();
143
   webViewRef = React.createRef();
146
 
144
 
147
   UNSAFE_componentWillMount() {
145
   UNSAFE_componentWillMount() {
148
-    if (this.props.startInLoadingState) {
149
-      this.setState({ viewState: WebViewState.LOADING });
150
-    }
151
-
152
     if (
146
     if (
153
       this.props.useWebKit === true &&
147
       this.props.useWebKit === true &&
154
       this.props.scalesPageToFit !== undefined
148
       this.props.scalesPageToFit !== undefined