# use-abuse

> useState alternative for functional components

Latest version **2.1.0** (published 2021-11-10) · The Unlicense license · 0 weekly downloads

## Install

```sh
npm install use-abuse
pnpm add use-abuse
yarn add use-abuse
bun add use-abuse
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2021-11-10 |
| First published | 2020-08-03 |
| Weekly downloads | 0 |
| License | The Unlicense |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | ohad1997 |
| Keywords | tiny, npm, package, useAbuse, react, hooks, react.js, react-hooks |

## Links

- npm: https://www.npmjs.com/package/use-abuse
- Repository: https://github.com/OhadBaehr/useAbuse
- Homepage: https://github.com/OhadBaehr/useAbuse#readme
- Issues: https://github.com/OhadBaehr/useAbuse/issues
- npm.io page: https://npm.io/package/use-abuse

## Dependencies (1)

- [react](https://npm.io/package/react.md) ^17.0

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

- 2.1.0 (latest) — 2021-11-10
- 2.0.0 — 2021-11-10
- 1.1.5 — 2020-08-03

## README

# useAbuse
new hook that act like the original setState but built for functional components

## npm
https://www.npmjs.com/package/use-abuse

## install:
```js
npm i 'use-abuse'
```

## import:
```js
import {useAbuse} from 'use-abuse'
```

## usage:
```js
const [state, setState] = useAbuse({ name: "larry" , visible: true, counter: 1 })

setState({ visible: false })
setState(prev => ({ counter: prev.counter + 1 }))//based on previous value
setState({ name: "beans", counter: 12 , visible: true})//multiple 
```

## example component:
```js
import React from 'react';
import { useAbuse } from 'use-abuse'

const Counter = () => {
    const [state, setState] = useAbuse({ counter: 0 })
    return (
        <button style={{ background: "black", width: "100%", color: "white", fontSize: 20, textAlign: "center", padding: 20 }}
            onClick={() => setState(prev => ({ counter: prev.counter + 1 }))}>
            {state.counter}
        </button>
    );
}

export default Counter;
```

## license:
this is released into the public domain, you can do whatever you want with this

my brother and i wrote this, if you like it and think it's worth it, you can buy us a beer

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