File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,26 @@ const Demo = () => {
3333 ] ) ;
3434 } , [ ] ) ;
3535
36+ const createFiveConfigs = React . useCallback ( ( ) => {
37+ setConfigList ( ( prevConfigList ) => {
38+ const startKey = keyRef . current ;
39+ keyRef . current += 5 ;
40+
41+ return [
42+ ...prevConfigList ,
43+ ...Array . from ( { length : 5 } , ( _ , index ) => {
44+ const key = startKey + index ;
45+
46+ return {
47+ key,
48+ duration : false ,
49+ content : `Config ${ key + 1 } ` ,
50+ } ;
51+ } ) ,
52+ ] ;
53+ } ) ;
54+ } , [ ] ) ;
55+
3656 const removeLastConfig = React . useCallback ( ( ) => {
3757 setConfigList ( ( prevConfigList ) => prevConfigList . slice ( 0 , - 1 ) ) ;
3858 } , [ ] ) ;
@@ -59,6 +79,9 @@ const Demo = () => {
5979 < button type = "button" onClick = { createConfig } >
6080 Add Config
6181 </ button >
82+ < button type = "button" onClick = { createFiveConfigs } >
83+ Add 5 Config
84+ </ button >
6285 < button type = "button" onClick = { removeLastConfig } >
6386 Remove Last Config
6487 </ button >
You can’t perform that action at this time.
0 commit comments