Skip to content

Commit d1aeeff

Browse files
brickspertttys026
authored andcommitted
feat: rename useControlledValue to useControllableValue (#99)
* feat: rename useControlledValue to useControllableValue
1 parent 6edd20c commit d1aeeff

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,29 @@ import useAPI, { configRequest } from './useAPI';
33
import useAsync from './useAsync';
44
import useLoadMore from './useLoadMore';
55
import useSearch from './useSearch';
6-
import useControlledValue from './useControlledValue';
6+
import useControllableValue from './useControllableValue';
77
import useDynamicList from './useDynamicList';
88
import useEventEmitter from './useEventEmitter';
99
import useVirtualList from './useVirtualList';
1010
import { configResponsive, useResponsive } from './useResponsive';
1111
import useSize from './useSize';
1212
import 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+
1421
export {
1522
useAntdTable,
1623
useAPI,
1724
useAsync,
1825
useLoadMore,
1926
useSearch,
2027
useControlledValue,
28+
useControllableValue,
2129
useDynamicList,
2230
useVirtualList,
2331
useResponsive,

src/useControlledValue/__tests__/index.test.ts renamed to src/useControllableValue/__tests__/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { renderHook, act } from '@testing-library/react-hooks';
22
import { 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 });
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
2-
name: useControlledValue
3-
route: /useControlledValue
2+
name: useControllableValue
3+
route: /useControllableValue
44
menu: '中台 hooks'
55
edit: false
66
sidebar: true
77
---
88

99
import { Playground } from 'docz';
10-
import useControlledValue from './index';
10+
import useControllableValue from './index';
1111
import { useState } from 'react';
1212
import { 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
7373
params:(
7474
props: object;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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',

0 commit comments

Comments
 (0)