0.5.6 • Published 4 years ago
@pepfar-react-lib/network-check v0.5.6
DHIS2 Network Check
Repo Owner: Ben Guaraldi @benguaraldi
Minimalistic REACT component to warn user they're offline or their 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 notistackUsage
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 startDon't forget to run tests
npm testAnd build with:
npm build