@opensrp/react-utils
TypeScript icon, indicating that this package has built-in type declarations

0.0.12 • Public • Published

React Utils

A couple of utils being used in opensrp-web that work with react

Installation

yarn add @opensrp/react-utils

Usage

This package currently exposes the following components:

Broken Page

This is a util component that is shown when a page runs into a non-recoverable error. it also comes with the useHandleBrokenPage hook that helps manage the workflow of a broken page

Props/ Configuration

title

Optional(string | defaults Something went wrong)

Error title

errorMessage

Optional(string | defaults Error)

Error description

homeUrl

Optional(string | defaults /)

url path to home page

Resource404

This is a util component shown when a requested resource is not found; the more canonical 404 component, is shown when a page is not yet bound to the routing system, this component is to be used within an existing page but where one or more resources to be shown on that page are deemed missing.

Props/ Configuration

title

Optional(string | defaults Sorry, the resource you requested for, does not exist)

Error title

errorMessage

Optional(string | defaults Error)

Error description

homeUrl

Optional(string | defaults /)

url path to home page

Code examples

import { Resource404, BrokenPage, useHandleBrokenPage } from '@opensrp/react-utils';

const Foo = () => {
  const { broken, handleBrokenPage } = useHandleBrokenPage;
  if (broken) {
    return <BrokenPage />;
  }
  if (!object) {
    return <Resource404 />;
  }
};

Readme

Keywords

none

Package Sidebar

Install

npm i @opensrp/react-utils

Weekly Downloads

1

Version

0.0.12

License

Apache-2.0

Unpacked Size

66.6 kB

Total Files

45

Last publish

Collaborators

  • opensrp-admin