Skip to content

Commit baf5f26

Browse files
committed
docs: improve maxCount demo
1 parent 8d63a07 commit baf5f26

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

examples/mutiple-with-maxCount.tsx

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
22
import TreeSelect from '../src';
33

44
export default () => {
5+
const [value, setValue] = useState<string[]>(['1']);
6+
57
const treeData = [
68
{
79
key: '1',
@@ -31,15 +33,33 @@ export default () => {
3133
title: '4',
3234
},
3335
];
34-
const onChange = () => {};
36+
37+
const onChange = (value: string[]) => {
38+
setValue(value);
39+
};
3540

3641
return (
37-
<TreeSelect
38-
style={{ width: 300 }}
39-
multiple
40-
maxCount={3}
41-
treeData={treeData}
42-
onChange={onChange}
43-
/>
42+
<>
43+
<h2>multiple with maxCount</h2>
44+
<TreeSelect
45+
style={{ width: 300 }}
46+
multiple
47+
maxCount={3}
48+
treeData={treeData}
49+
onChange={onChange}
50+
value={value}
51+
/>
52+
53+
<h2>checkable with maxCount</h2>
54+
<TreeSelect
55+
style={{ width: 300 }}
56+
multiple
57+
treeCheckable
58+
maxCount={3}
59+
treeData={treeData}
60+
onChange={onChange}
61+
value={value}
62+
/>
63+
</>
4464
);
4565
};

0 commit comments

Comments
 (0)