Removed useless state and cleaned componentWillMount

This commit is contained in:
Thibault Malbranche 2018-09-19 01:33:57 +02:00
parent 71cc1042f8
commit aca9c2e31f
2 changed files with 2 additions and 16 deletions

View File

@ -54,7 +54,6 @@ const defaultRenderLoading = () => (
type State = {| type State = {|
viewState: WebViewState, viewState: WebViewState,
lastErrorEvent: ?WebViewError, lastErrorEvent: ?WebViewError,
startInLoadingState: boolean,
|}; |};
/** /**
@ -71,19 +70,12 @@ class WebView extends React.Component<WebViewSharedProps, State> {
}; };
state = { state = {
viewState: WebViewState.IDLE, viewState: this.props.startInLoadingState ? WebViewState.LOADING : WebViewState.IDLE,
lastErrorEvent: null, lastErrorEvent: null,
startInLoadingState: true,
}; };
webViewRef = React.createRef(); webViewRef = React.createRef();
UNSAFE_componentWillMount() {
if (this.props.startInLoadingState) {
this.setState({ viewState: WebViewState.LOADING });
}
}
render() { render() {
let otherView = null; let otherView = null;

View File

@ -76,7 +76,6 @@ const JSNavigationScheme = 'react-js-navigation';
type State = {| type State = {|
viewState: WebViewState, viewState: WebViewState,
lastErrorEvent: ?WebViewError, lastErrorEvent: ?WebViewError,
startInLoadingState: boolean,
|}; |};
const DataDetectorTypes = [ const DataDetectorTypes = [
@ -137,18 +136,13 @@ class WebView extends React.Component<WebViewSharedProps, State> {
}; };
state = { state = {
viewState: WebViewState.IDLE, viewState: this.props.startInLoadingState ? WebViewState.LOADING : WebViewState.IDLE,
lastErrorEvent: null, lastErrorEvent: null,
startInLoadingState: true,
}; };
webViewRef = React.createRef(); webViewRef = React.createRef();
UNSAFE_componentWillMount() { UNSAFE_componentWillMount() {
if (this.props.startInLoadingState) {
this.setState({ viewState: WebViewState.LOADING });
}
if ( if (
this.props.useWebKit === true && this.props.useWebKit === true &&
this.props.scalesPageToFit !== undefined this.props.scalesPageToFit !== undefined