# react-plug

> Custom plugable hooks library

Latest version **0.0.13** (published 2019-04-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-plug
pnpm add react-plug
yarn add react-plug
bun add react-plug
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.13 |
| Published | 2019-04-08 |
| First published | 2018-10-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 28.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | nobuti |
| Maintainers | nobuti |
| Keywords | react, hooks |

## Links

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

## 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

- 0.0.13 (latest) — 2019-04-08
- 0.0.11-0 (next) — 2018-11-25
- 0.0.12 — 2019-04-08
- 0.0.11 — 2018-11-25
- 0.0.10 — 2018-11-02
- 0.0.9 — 2018-11-02
- 0.0.8 — 2018-10-31
- 0.0.7 — 2018-10-31
- 0.0.6 — 2018-10-28
- 0.0.6-0 — 2018-10-28
- 0.0.5 — 2018-10-28
- 0.0.5-0 — 2018-10-28
- 0.0.4 — 2018-10-28
- 0.0.3 — 2018-10-28
- 0.0.2 — 2018-10-28
- … 1 more at https://npm.io/package/react-plug/versions

## README

### react-plug

🔥 Small utility library implementing react hooks

## Install

```bash
yarn add react-plug
```

## Usage

```
import React from "react";
import ReactDOM from "react-dom";

import {useWindowSize} from "react-plug";

import "./styles.css";

const App = () => {
  const size = useWindowSize();

  return (
    <div className="App">
      <h1>Hello React Hooks</h1>
      <h2>Resize the window and see its size below</h2>
      {size && (
        <div>
          ({size.width}, {size.height})
        </div>
      )}
    </div>
  );
};

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
```

### Example

[View example in CodeSandbox](https://codesandbox.io/s/vq97rq9kv0)

### useMount

```jsx
useMount(() => console.log(`I'm mounted`));
```

### useUnMount

```jsx
useUnMount(() => console.log(`I'm going to unmount`));
```


### useWindowSize

```jsx
const size = useWindowSize({delay: 50});
```

Options:
- delay: number of miliseconds to debounce. Default to 100 miliseconds.

### useKeypress

```jsx
const key = useKeypress({keys: [13, 27]});
```

Options:
- keys: array of key codes you want to catch.

### useOnline

```jsx
const online = useOnline();
```

### usePageHidden

```jsx
const pageHidden = usePageHidden();
```

### useScrollPosition

```jsx
const {x, y} = useScrollPosition();
```

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