@@ -8,7 +8,7 @@ import useMergedState from '../src/hooks/useMergedState';
88import useMobile from '../src/hooks/useMobile' ;
99import useState from '../src/hooks/useState' ;
1010import useSyncState from '../src/hooks/useSyncState' ;
11- import usePropState from '../src/hooks/usePropState ' ;
11+ import useControlledState from '../src/hooks/useControlledState ' ;
1212
1313global . disableUseId = false ;
1414
@@ -318,13 +318,16 @@ describe('hooks', () => {
318318 } ) ;
319319 } ) ;
320320
321- describe ( 'usePropState ' , ( ) => {
321+ describe ( 'useControlledState ' , ( ) => {
322322 const FC : React . FC < {
323323 value ?: string ;
324324 defaultValue ?: string | ( ( ) => string ) ;
325325 } > = props => {
326326 const { value, defaultValue } = props ;
327- const [ val , setVal ] = usePropState < string > ( defaultValue ?? null , value ) ;
327+ const [ val , setVal ] = useControlledState < string > (
328+ defaultValue ?? null ,
329+ value ,
330+ ) ;
328331 return (
329332 < >
330333 < input
@@ -367,7 +370,7 @@ describe('hooks', () => {
367370 let renderTimes = 0 ;
368371
369372 const Test = ( ) => {
370- const [ val , setVal ] = usePropState ( 0 ) ;
373+ const [ val , setVal ] = useControlledState ( 0 ) ;
371374
372375 React . useEffect ( ( ) => {
373376 renderTimes += 1 ;
@@ -385,7 +388,7 @@ describe('hooks', () => {
385388
386389 it ( 'React 18 should not reset to undefined' , ( ) => {
387390 const Demo = ( ) => {
388- const [ val ] = usePropState ( 33 , undefined ) ;
391+ const [ val ] = useControlledState ( 33 , undefined ) ;
389392
390393 return < div > { val } </ div > ;
391394 } ;
@@ -401,7 +404,7 @@ describe('hooks', () => {
401404
402405 it ( 'uncontrolled to controlled' , ( ) => {
403406 const Demo : React . FC < Readonly < { value ?: number } > > = ( { value } ) => {
404- const [ mergedValue , setMergedValue ] = usePropState < number > (
407+ const [ mergedValue , setMergedValue ] = useControlledState < number > (
405408 ( ) => 233 ,
406409 value ,
407410 ) ;
@@ -437,7 +440,7 @@ describe('hooks', () => {
437440
438441 it ( 'should alway use option value' , ( ) => {
439442 const Test : React . FC < Readonly < { value ?: number } > > = ( { value } ) => {
440- const [ mergedValue , setMergedValue ] = usePropState < number > (
443+ const [ mergedValue , setMergedValue ] = useControlledState < number > (
441444 undefined ,
442445 value ,
443446 ) ;
@@ -462,7 +465,7 @@ describe('hooks', () => {
462465 let count = 0 ;
463466
464467 const Demo : React . FC = ( ) => {
465- const [ ] = usePropState ( undefined ) ;
468+ const [ ] = useControlledState ( undefined ) ;
466469 count += 1 ;
467470 return null ;
468471 } ;
0 commit comments