# @opensrp/react-utils

> A couple of utils that work with react

Latest version **0.0.12** (published 2021-07-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @opensrp/react-utils
pnpm add @opensrp/react-utils
yarn add @opensrp/react-utils
bun add @opensrp/react-utils
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.12 |
| Published | 2021-07-26 |
| First published | 2020-11-12 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 65 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 33 |
| Author | OpenSRP Engineering |
| Maintainers | opensrp-admin |

## Links

- npm: https://www.npmjs.com/package/@opensrp/react-utils
- Repository: https://github.com/opensrp/web
- Homepage: https://github.com/opensrp/web#readme
- Issues: https://github.com/opensrp/web/issues
- npm.io page: https://npm.io/package/@opensrp/react-utils

## Dependencies (9)

- [antd](https://npm.io/package/antd.md) ^4.6.3
- [@onaio/utils](https://npm.io/package/@onaio/utils.md) ^0.0.1
- [@onaio/gatekeeper](https://npm.io/package/@onaio/gatekeeper.md) ^0.1.1
- [@opensrp/pkg-config](https://npm.io/package/@opensrp/pkg-config.md) ^0.0.9
- [@onaio/session-reducer](https://npm.io/package/@onaio/session-reducer.md) ^0.0.12
- [@opensrp/notifications](https://npm.io/package/@opensrp/notifications.md) ^0.0.5
- [@opensrp/server-service](https://npm.io/package/@opensrp/server-service.md) ^0.0.17
- [@onaio/connected-private-route](https://npm.io/package/@onaio/connected-private-route.md) ^0.0.11
- [@onaio/connected-reducer-registry](https://npm.io/package/@onaio/connected-reducer-registry.md) ^0.0.3

## Recent versions

- 0.0.12 (latest) — 2021-07-26
- 0.0.11 — 2021-06-30
- 0.0.10 — 2021-06-10
- 0.0.9 — 2021-06-10
- 0.0.8 — 2021-06-03
- 0.0.6 — 2021-02-24
- 0.0.5 — 2021-02-23
- 0.0.3 — 2021-02-18
- 0.0.1 — 2020-11-12
- 0.0.0 — 2020-11-12

## README

# React Utils

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

## Installation

```sh
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

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

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

---
_Source: https://npm.io/package/@opensrp/react-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
