Coder Social home page Coder Social logo

wangdicoder / react-native-progress-webview Goto Github PK

View Code? Open in Web Editor NEW
22.0 1.0 5.0 68 KB

🧩 A wrapper of React Native WebView to provide a loading bar on the top of the browser.

License: MIT License

JavaScript 100.00%
react-native webview react-native-webview progress-bar loading-bar react-native-progress-webview

react-native-progress-webview's Introduction

React Native Progress WebView

npm npm star this repo GitHub

React Native Progress WebView is a wrapper of React Native WebView to provide a loading bar on the top of the browser.

Platforms Supported

  • iOS (both UIWebView and WKWebView)
  • Android

Getting Started

Firstly, read the Getting Started Guide on React Native WebView page to configure the webview component.

Then

$ npm install --save react-native-progress-webview

Usage

Import the ProgressWebView component from react-native-progress-webview and use it like so:

import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import ProgressWebView from "react-native-progress-webview";

// ...
class App extends Component {
  render() {
    return (
      <ProgressWebView source={{ uri: 'https://facebook.github.io/react-native/' }} />
    );
  }
}

API

React Native Progress Webview supports all React Native Webview props. Read the API Reference to explore. There are a couple of exclusive props related to the loading bar.

prop type default description
height number 3 the height of loading bar
color string #3B78E7 the normal color of loading bar
errorColor string #f30 the error color of loading bar
disappearDuration number 300 the visible duration after the webview finishes the loading

Common issues

How can I use ref to get WebView methods?

It's same as using raw WebView. You can just pass a ref prop to get the instance.

class App extends Component {
  constructor(props){
    super(props);
    this.ref = React.createRef();
  }

  componentDidMount() {
    console.log(this.ref.current);
  }

  render() {
    return (
      <ProgressWebView
        ref={this.ref}
        source={{ uri: 'https://facebook.github.io/react-native/' }} 
      />
    );
  }
}

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.