Skip to content

Commit 71219ac

Browse files
committed
docs: add batch notification list demo action
1 parent 0410374 commit 71219ac

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

docs/examples/NotificationList.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff 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>

0 commit comments

Comments
 (0)