Skip to content

Commit b0fc317

Browse files
Chris Bobbegnprice
Chris Bobbe
authored andcommitted
MessageList: Fix white flicker in dark mode on iOS while WebView is initializing.
Fixes: zulip#2914. Use startInLoadingState and renderLoading props to present a blank, transparent View, during the first load. react-native-webview does not specify exactly what work is being done during this "first load," but it's fairly clear (https://github.com/react-native-community/react-native-webview/blob/master/docs/Reference.md#startinloadingstate) that it only happens (and our blank View will only show) on the first load of the WebView, and not during API calls, etc.
1 parent fc660d6 commit b0fc317

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/webview/MessageList.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow strict-local */
22
import React, { Component } from 'react';
3-
import { Platform } from 'react-native';
3+
import { Platform, View } from 'react-native';
44
import { WebView } from 'react-native-webview';
55
import type { WebViewNavigation } from 'react-native-webview';
66

@@ -199,6 +199,15 @@ class MessageList extends Component<Props> {
199199
return false;
200200
};
201201

202+
renderLoading = () => {
203+
const style = {
204+
backgroundColor: 'transparent',
205+
width: '100%',
206+
height: '100%',
207+
};
208+
return <View style={style} />;
209+
};
210+
202211
render() {
203212
const { styles: contextStyles } = this.context;
204213
const {
@@ -290,6 +299,8 @@ class MessageList extends Component<Props> {
290299
return (
291300
<WebView
292301
useWebKit
302+
startInLoadingState
303+
renderLoading={this.renderLoading}
293304
source={{ baseUrl, html }}
294305
originWhitelist={['file://']}
295306
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}

0 commit comments

Comments
 (0)