# react-lifecycle-gate

> A lightweight component to access lifecycle hooks

Latest version **1.1.2** (published 2018-06-11) · ISC license · 0 weekly downloads

## Install

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

## 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-06-11 |
| First published | 2018-05-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | fresidue |
| Maintainers | fresidue |
| Keywords | react, lifecycle, hooks, gate, component |

## Links

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

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2018-06-11
- 1.1.1 — 2018-05-30
- 1.1.0 — 2018-05-20
- 1.0.2 — 2018-05-12
- 1.0.1 — 2018-05-12
- 1.0.0 — 2018-05-12

## README

# react-lifecycle-gate
A lightweight component to which lifecycle hooks can easily be attached as props. Similar to [react-lifecycle-component](https://github.com/JamieDixon/react-lifecycle-component) but slightly simpler

`npm i react-lifecycle-gate --save`

## Usage

Suppose you want to use a pure functional component, and need to trigger some stuffs on e.g. componentDidMount, just wrap your content in a lifecycle gate and you're done.

```javascript
import LifecycleGate from 'react-lifecycle-gate';

const initStuffs = () => {};

export const JankyComponent = props => (
  <LifecycleGate
    willMount={initStuffs}
    willUpdate={() => {
      console.log('fresh props just arrived');
    }} >
    <p>Children get rendered if included. If not, the callbacks get called anyways of course</p>
  </LifecycleGate>
);
```
## Supported properties

#### willMount
#### didMount
#### willUnmount
#### willReceiveProps
#### willUpdate
#### didUpdate

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