We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cascader
2.57.0
react/react-dom 版本需使用 18.2.0 复现 codesanbox
import { Button } from '@douyinfe/semi-ui'; import React, { useState, useEffect, useRef } from "react"; import { Modal, Form, Cascader } from "@douyinfe/semi-ui"; const initialData = [ { label: "Node1", value: "0-0", }, { label: "Node2", value: "0-1", }, { label: "Node3", value: "0-2", isLeaf: true, }, ]; export default function App() { const [value, setValue] = useState([]); const onChange = useEffect((value) => { setValue(value); },[]); const [data, setData] = useState(initialData); const updateTreeDataC = (list, value, children) => { return list.map((node) => { if (node.value === value) { return { ...node, children }; } if (node.children) { return { ...node, children: updateTreeDataC(node.children, value, children), }; } return node; }); }; const onLoadDataC = (selectedOpt) => { const targetOpt = selectedOpt[selectedOpt.length - 1]; const { label, value } = targetOpt; return new Promise((resolve) => { if (targetOpt.children) { resolve(); return; } setTimeout(() => { setData((origin) => updateTreeDataC(origin, value, [ { label: `${label} - 1`, value: `${label}-1`, isLeaf: selectedOpt.length > 1, }, { label: `${label} - 2`, value: `${label}-2`, isLeaf: selectedOpt.length > 1, }, ]) ); resolve(); }, 1000); }); }; return ( <> <div> <Cascader value={value} onChange={onChange} style={{ width: 300 }} treeData={data} loadData={onLoadDataC} placeholder="Please select" /> </div> </> ); }
- OS: - browser:
No response
The text was updated successfully, but these errors were encountered:
YyumeiZhang
No branches or pull requests
Is there an existing issue for this?
Which Component
Cascader
Semi Version
2.57.0
Current Behavior
Expected Behavior
Steps To Reproduce
react/react-dom 版本需使用 18.2.0
复现 codesanbox
ReproducibleCode
Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: