# react-lifecycle-components

> React lifecycle as components

Latest version **1.1.2** (published 2018-10-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-lifecycle-components
pnpm add react-lifecycle-components
yarn add react-lifecycle-components
bun add react-lifecycle-components
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2018-10-31 |
| First published | 2018-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 150.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sam Pettersson |
| Maintainers | sampettersson |

## Links

- npm: https://www.npmjs.com/package/react-lifecycle-components
- Repository: https://github.com/HedvigInsurance/react-lifecycle-components
- Homepage: https://github.com/HedvigInsurance/react-lifecycle-components#readme
- Issues: https://github.com/HedvigInsurance/react-lifecycle-components/issues
- npm.io page: https://npm.io/package/react-lifecycle-components

## Recent versions

- 1.1.2 (latest) — 2018-10-31
- 1.1.1 — 2018-09-19
- 1.1.0 — 2018-09-19
- 1.0.0 — 2018-08-27

## README

# React lifecycle as components
An alternative to writing classes, here are some declarative components you can use to keep your code clean 👌🏻

Supports: React DOM and React Native.

## Install

```
    yarn install react-lifecycle-components
```

## Components

### Mount

When you want to perform a side-effect on mount, like sending a tracking event 🚀, starting an animation ✨, or something like that.

```javascript
<Mount on={() => console.log("I was mounted!")} />
```

### Unmount

Basically the same as `Mount` but calls `on` when the component will unmount 😄

```javascript
<Unmount on={() => console.log("I will be unmounted!")} />
```

### Update

When you want to be notified when a prop was changed. 👌🏻 Works with both non-objects (simple equality check) or with objects (shallow equality check).

```javascript
    <Update<string> was={(prevWatched, currentWatched) => console.log("I was updated!")} watched="hello" />

    interface AnObject {
        anObject: string;
    }

    <Update<AnObject> was={(prevWatched, currentWatched) => console.log("I was updated!")} watched={{ anObject: "hello" }} />
```

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