NOTE: This repo is no longer in use. Please use https://github.com/pepfar-datim/javascript-libraries instead.
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/
npm i @pepfar-react-lib/network-check
npm i notistack
import {SnackbarProvider} from 'notistack';
import {NetworkCheck} from '@pepfar-react-lib/network-check';
<SnackbarProvider>
<NetworkCheck intervalMs={5000} baseUrl='https://play.dhis2.org/'/>
</SnackbarProvider>
<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.
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

