How to use the react-native-offline.withNetworkConnectivity function in react-native-offline

To help you get started, we’ve selected a few react-native-offline examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Osedea / react-native-offline-first-example / js / api.js View on Github external
// @flow

import { create } from 'apisauce';
import { withNetworkConnectivity } from 'react-native-offline';

export const API_URL = __DEV__
    ? 'http://localhost:3030'
    : 'http://138.197.149.40';
export const withCheckInternet = withNetworkConnectivity({
    pingServerUrl: API_URL,
});

const api = create({
    baseURL: API_URL,
});

api.addResponseTransform((response) => {
    if (response.status >= 400 || !response.ok) {
        const error = new Error(response.status || response.problem);

        error.status = response.status;
        error.response = response;

        throw error;
    }

react-native-offline

Handy toolbelt to deal with offline mode in React Native applications. Cross-platform, provides a smooth redux integration.

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis