Skip to content

Commit

Permalink
fix: 创建 treeStore时传入 keys
Browse files Browse the repository at this point in the history
  • Loading branch information
jsonz1993 committed Apr 8, 2022
1 parent db6b79c commit 677f4e2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cascader/Cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,21 @@ const Cascader: React.FC<CascaderProps> = (props) => {
/**
* build tree
*/
const { disabled, options = [], keys, checkStrictly = false, lazy = true, load, valueMode = 'onlyLeaf' } = props;
const { disabled, options = [], keys = {}, checkStrictly = false, lazy = true, load, valueMode = 'onlyLeaf' } = props;

useEffect(() => {
if (!options.length) return;
if (!treeStore) {
const createStore = (onLoad: () => void) => {
const treePropsKeys = {
...keys,
children: typeof keys.children === 'string' ? keys.children : 'children',
};

const treeProps = {
onLoad,
options,
keys: treePropsKeys,
};
const store = new TreeStore(treeProps);
store.append(options);
Expand All @@ -119,7 +125,7 @@ const Cascader: React.FC<CascaderProps> = (props) => {
treeStoreExpendEffect(treeStore, value, []);
treeNodesEffect(inputVal, treeStore, setTreeNodes);
}
}, [inputVal, options, value, treeStore]);
}, [inputVal, options, value, treeStore, keys]);

useEffect(() => {
if (!treeStore) return;
Expand Down

0 comments on commit 677f4e2

Please sign in to comment.