# use-merge-value

> Easier to write a controlled component

Latest version **1.2.0** (published 2023-03-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-merge-value
pnpm add use-merge-value
yarn add use-merge-value
bun add use-merge-value
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2023-03-21 |
| First published | 2019-12-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 23 |
| Maintainers | chenshuai2144 |

## Links

- npm: https://www.npmjs.com/package/use-merge-value
- Repository: https://github.com/chenshuai2144/merge-value-hooks
- Homepage: https://github.com/chenshuai2144/merge-value-hooks#readme
- Issues: https://github.com/chenshuai2144/merge-value-hooks/issues
- npm.io page: https://npm.io/package/use-merge-value

## Recent versions

- 1.2.0 (latest) — 2023-03-21
- 1.1.0 — 2023-03-02
- 1.0.2 — 2020-06-06
- 1.0.1 — 2019-12-10
- 1.0.0 — 2019-12-10
- 0.0.1 — 2019-12-10

## README

# use-merge-value

Easier to write a controlled component

此 hooks 可以轻松的实现一个受控组件。使用方式类似于 useState ，支持通过第二个参数传入 { value, onChange} 来覆盖掉默认的 value 与 setValue。

## Usage

```sh
yarn add use-merge-value
```

```tsx
import React, { useState } from 'react';
import useMergeState from 'use-merge-value';

const ControlledInput: React.FC<{ value: string; onChange: (value: string) => void }> = props => {
  const [value, setValue] = useMergeState('', props);
  return (
    <div>
      <input value={value} onChange={e => setValue(e.target.value)}></input>{' '}
    </div>
  );
};
```

## LICENSE

MIT

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