You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
837816638@qq.com b02b851162
工商大学管理系统代码
5 years ago
..
dist 工商大学管理系统代码 5 years ago
examples 工商大学管理系统代码 5 years ago
src 工商大学管理系统代码 5 years ago
.fatherrc.ts 工商大学管理系统代码 5 years ago
.prettierignore 工商大学管理系统代码 5 years ago
.prettierrc 工商大学管理系统代码 5 years ago
LICENSE 工商大学管理系统代码 5 years ago
README.md 工商大学管理系统代码 5 years ago
package.json 工商大学管理系统代码 5 years ago
tsconfig.json 工商大学管理系统代码 5 years ago
typings.d.ts 工商大学管理系统代码 5 years ago

README.md

use-merge-value

Easier to write a controlled component

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

Usage

yarn add use-merge-value
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