1.2.0 • Published 3 years ago

use-merge-value v1.2.0

Weekly downloads
7,035
License
MIT
Repository
github
Last release
3 years ago

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

mikorab-uupm-uinsn_webumi-antdfk_tablepower-deisgnliuzy-ant-design-projyswsdssdfdfdsafdtedsssswdswscra-template-gtja-czant-views@hzerojs/layoutsimple-antd-management-fast-framework@infinitebrahmanuniverse/nolb-use-m@everything-registry/sub-chunk-3027weui-react-v2dumi-theme-easyxaijostoolsjxt-libsjxt-rollup-libjxt-components-testkitchen-flow-editorhuemix-pro-layouthumxhoonghu-layoutluighif@xcomponents/storage@xauth/react-lock@unitalkai/ui@toboto/lobehub-ui@yuntijs/ui@zangai-family/pro-table@zven/pro-layoutadmin-frontend-componentaibit-uiahax-formtableauto-create-editorantd-pro-table-felixfixedantd-styleaoligeiant-design-atomgeoscene-ant-pro-layoutdw-mx-layout-antdprodumi-theme-yuntidumi-theme-aipmhubdumi-theme-antd-styledumi-theme-antd-style-nbbdumi-theme-ariettadumi-theme-ayahubdumi-theme-lobehubdumi-theme-multiway-docsdumi-theme-xieyezidtusercenterdtusercentercomperp-tablefe-antd-wealth-mgtfc-headerfk_mfk_tb@bmstravel/nvp-pro-table@bmstravel/pro-layout@bmstravel/pro-table@chat2db/ui@cfmm/umi-plugins-ui@chaoswise/ui@bentwnghk/chat@bentwnghk/ui@bashid/pro-editor@ayahub/uicustom-pro-layoutdata-service-bbtcustom-antd-pro-tabledc-chartsdaichao-dale_template_adminbn-tsp-toolsbrainyai-uiboncboteui@admin-layout/ant-design-pro@admin-layout/tailwind-design-pro@aipmorg/chat@aipmorg/ui@aipmui/ui@ant-design/form@ant-design/pro-editor@ant-design/pro-flow@ant-design/pro-flow-editor@arietta-studio/readme-wizard@arietta-studio/ui@arvinxu/asset-gallery@arvinxu/float-label-input@arvinxu/image-gallery@arvinxu/journal-map@arvinxu/journey-map@angeloreppucci/ant-design-pro-layout@ali-dayu/qi@ali-dayu/qi-fusion@amirkarimi/antd-pro-layout-with-ssr@asany/components@jthinking/pro-editorlobe-uisongbai-pro-table
1.2.0

3 years ago

1.1.0

3 years ago

1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.1

6 years ago