React Native Show Progress bar While Loading WebView Android iOS

This tutorial is the second part of our Previous React Native Simple WebView Tutorial. In this tutorial we would going to create a react native application with WebView component and Show Progress bar – ActivityIndicator on middle of screen just above WebView on Website loading time and hide the Progress bar after done loading WebView and show Website using renderLoading={} and startInLoadingState={} method.

Contents in this project Show Progress bar While Loading WebView in Android iOS Example Tutorial :

1. Import StyleSheet, WebView, Platform and ActivityIndicator component in your react native project.

2. Create a function named as ActivityIndicatorLoadingView() . Inside this function we would make a ActivityIndicator component View in return block. This function would render the ActivityIndicator just middle of screen above WebView.

3. Create WebView component inside render’s return block.

renderLoading : Call the ActivityIndicatorLoadingView function which would render the ActivityIndicator .

startInLoadingState : This would allow us to start the render loading view.

4. Create Custom CSS Style Class for WebView and ActivityIndicator.

5. Complete source code for App.js File :

Screenshot in Android device :

Show Progress bar

Screenshot in iOS device :