File tree Expand file tree Collapse file tree 4 files changed +20
-12
lines changed
Expand file tree Collapse file tree 4 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -3,21 +3,29 @@ import useAPI, { configRequest } from './useAPI';
33import useAsync from './useAsync' ;
44import useLoadMore from './useLoadMore' ;
55import useSearch from './useSearch' ;
6- import useControlledValue from './useControlledValue ' ;
6+ import useControllableValue from './useControllableValue ' ;
77import useDynamicList from './useDynamicList' ;
88import useEventEmitter from './useEventEmitter' ;
99import useVirtualList from './useVirtualList' ;
1010import { configResponsive , useResponsive } from './useResponsive' ;
1111import useSize from './useSize' ;
1212import useLocalStorageState from './useLocalStorageState' ;
1313
14+ const useControlledValue : typeof useControllableValue = function ( ...args ) {
15+ console . warn (
16+ 'useControlledValue is deprecated and will be removed in the next major version. Please use useControllableValue instead.' ,
17+ ) ;
18+ return useControllableValue ( ...args ) ;
19+ } ;
20+
1421export {
1522 useAntdTable ,
1623 useAPI ,
1724 useAsync ,
1825 useLoadMore ,
1926 useSearch ,
2027 useControlledValue ,
28+ useControllableValue ,
2129 useDynamicList ,
2230 useVirtualList ,
2331 useResponsive ,
Original file line number Diff line number Diff line change 11import { renderHook , act } from '@testing-library/react-hooks' ;
22import { useCallback } from 'react' ;
3- import useControlledValue , { Options , Props } from '../index' ;
3+ import useControllableValue , { Options , Props } from '../index' ;
44
5- describe ( 'useControlledValue ' , ( ) => {
5+ describe ( 'useControllableValue ' , ( ) => {
66 it ( 'should be defined' , ( ) => {
7- expect ( useControlledValue ) . toBeDefined ( ) ;
7+ expect ( useControllableValue ) . toBeDefined ( ) ;
88 } ) ;
99
1010 const setUp = ( props ?: Props , options ?: Options ) : any =>
11- renderHook ( ( ) => useControlledValue ( props , options ) ) ;
11+ renderHook ( ( ) => useControllableValue ( props , options ) ) ;
1212
1313 it ( 'defaultValue should work' , ( ) => {
1414 const hook = setUp ( { defaultValue : 1 } ) ;
Original file line number Diff line number Diff line change 11---
2- name : useControlledValue
3- route : /useControlledValue
2+ name : useControllableValue
3+ route : /useControllableValue
44menu : ' 中台 hooks'
55edit : false
66sidebar : true
77---
88
99import { Playground } from ' docz' ;
10- import useControlledValue from ' ./index' ;
10+ import useControllableValue from ' ./index' ;
1111import { useState } from ' react' ;
1212import { InputNumber , Button } from ' antd' ;
1313
14- # useControlledValue
14+ # useControllableValue
1515
1616一个帮你处理受控组件中受控值的 Hook。
1717
@@ -22,7 +22,7 @@ import { InputNumber, Button } from 'antd';
2222 ()=> {
2323
2424 const ControlledComponent = (props ) => {
25- const [state, setState] = useControlledValue (props );
25+ const [state, setState] = useControllableValue (props );
2626
2727 return (
2828 <InputNumber
@@ -68,7 +68,7 @@ import { InputNumber, Button } from 'antd';
6868## API
6969
7070```
71- const [state, setState] = useControlledValue (params);
71+ const [state, setState] = useControllableValue (params);
7272
7373params:(
7474 props: object;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ export interface Props {
1111 [ key : string ] : any ;
1212}
1313
14- export default function useControlledValue < T > ( props : Props = { } , options : Options = { } ) {
14+ export default function useControllableValue < T > ( props : Props = { } , options : Options = { } ) {
1515 const {
1616 defaultValuePropName = 'defaultValue' ,
1717 valuePropName = 'value' ,
You can’t perform that action at this time.
0 commit comments