File tree 2 files changed +12
-0
lines changed
packages/react-search-select
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -411,6 +411,7 @@ const Demo = () => {
411
411
];
412
412
const [option , setOption ] = React .useState (selectOption);
413
413
const [loading , setLoading ] = React .useState (false );
414
+ const refForm = React .useRef ()
414
415
415
416
function handleSearch (e ) {
416
417
setLoading (true )
@@ -421,9 +422,14 @@ const Demo = () => {
421
422
}, 500 );
422
423
}
423
424
425
+ const reSetForm = () => {
426
+ console .log (' form' , refForm .current .resetForm ())
427
+ }
428
+
424
429
return (
425
430
< div>
426
431
< Form
432
+ ref= {refForm}
427
433
onSubmitError= {(error ) => {
428
434
if (error .filed ) {
429
435
return { ... error .filed };
@@ -500,6 +506,9 @@ const Demo = () => {
500
506
< Col fixed>
501
507
< Button disabled= {! canSubmit ()} type= " primary" htmlType= " submit" > 提交< / Button>
502
508
< / Col>
509
+ < Col fixed>
510
+ < Button onClick= {reSetForm}> 重置< / Button>
511
+ < / Col>
503
512
< / Row>
504
513
< Row>
505
514
< Col>
Original file line number Diff line number Diff line change @@ -99,6 +99,9 @@ export default function SearchSelect(props: SearchSelectProps) {
99
99
useEffect ( ( ) => {
100
100
if ( valueVerify ( value ) ) {
101
101
selectedValueChange ( value ! ) ;
102
+ } else {
103
+ setSelectedValue ( [ ] ) ;
104
+ setSelectedLabel ( '' ) ;
102
105
}
103
106
} , [ JSON . stringify ( value ) ] ) ;
104
107
You can’t perform that action at this time.
0 commit comments