From c1ad568542ce80b00a06b2dd1549476bf89e8400 Mon Sep 17 00:00:00 2001 From: coldice945 Date: Tue, 12 Oct 2021 11:43:10 +0800 Subject: [PATCH] fix: If use treeData props, treeNodeLabelProp does not work when it is set later --- src/generate.tsx | 1 + src/hooks/useSelectValues.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/generate.tsx b/src/generate.tsx index 64d06c6c..a21656ca 100644 --- a/src/generate.tsx +++ b/src/generate.tsx @@ -342,6 +342,7 @@ export default function generate(config: { getEntityByValue, getEntityByKey, getLabelProp: getTreeNodeLabelProp, + treeNodeLabelProp, }); const triggerChange = ( diff --git a/src/hooks/useSelectValues.ts b/src/hooks/useSelectValues.ts index b2e55003..0a2e03ad 100644 --- a/src/hooks/useSelectValues.ts +++ b/src/hooks/useSelectValues.ts @@ -20,6 +20,7 @@ interface Config { ignoreDisabledCheck?: boolean, ) => FlattenDataNode; getLabelProp: (entity: FlattenDataNode, value: RawValueType) => React.ReactNode; + treeNodeLabelProp?: string; } /** Return */ @@ -33,6 +34,7 @@ export default function useSelectValues( showCheckedStrategy, conductKeyEntities, getLabelProp, + treeNodeLabelProp, }: Config, ): LabelValueType[] { return React.useMemo(() => { @@ -55,5 +57,5 @@ export default function useSelectValues( } return getRawValueLabeled(mergedRawValues, value, getEntityByValue, getLabelProp); - }, [rawValues, value, treeConduction, showCheckedStrategy, getEntityByValue]); + }, [rawValues, value, treeConduction, showCheckedStrategy, getEntityByValue, treeNodeLabelProp]); }