Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Latest commit

 

History

History
52 lines (38 loc) · 1.37 KB

README.md

File metadata and controls

52 lines (38 loc) · 1.37 KB

NOTE: This repo is no longer in use. Please use https://github.com/pepfar-datim/javascript-libraries instead.

DHIS2 Network Check

Repo Owner: Ben Guaraldi @benguaraldi

Minimalistic REACT component to warn user they're offline or their session expired.

you're offline your session expired

It's based on notistack https://www.npmjs.com/package/notistack
Which uses amazing REACT Material UI Snackbar https://material-ui.com/components/snackbars/

Installation

npm i @pepfar-react-lib/network-check
npm i notistack

Usage

import {SnackbarProvider} from 'notistack';
import {NetworkCheck} from '@pepfar-react-lib/network-check';

<SnackbarProvider>
    <NetworkCheck intervalMs={5000} baseUrl='https://play.dhis2.org/'/>
</SnackbarProvider>

Notes

<NetworkCheck/> component can be only used inside <SnackbarProvider> context.

Why? <SnackbarProvider> manages output of info/alert messages. <NetworkCheck/> will share one instance of <SnackbarProvider> in your app with other services. Rather than overlapping over another existing instance.

Development

git clone https://github.com/dhis2-app/network-check.git && cd network-check 
npm install
npm start

Don't forget to run tests

npm test

And build with:

npm build