diff --git a/src/components/selectors/WellTreeSelector.tsx b/src/components/selectors/WellTreeSelector.tsx index f354d07..38ff425 100755 --- a/src/components/selectors/WellTreeSelector.tsx +++ b/src/components/selectors/WellTreeSelector.tsx @@ -54,7 +54,7 @@ const getLabel = (wellsTree: TreeNodeData[], value?: string): string | undefined break default: break } - return value + return 'Ошибка! Скважина не найдена!' } export const WellTreeSelector = memo(({ ...other }) => { @@ -100,14 +100,9 @@ export const WellTreeSelector = memo(({ ...other }) => { ) }, []) - useEffect(() => { - setValue(getLabel(wellsTree, routeMatch?.url)) - }, [wellsTree, routeMatch]) + useEffect(() => setValue(getLabel(wellsTree, routeMatch?.url)), [wellsTree, routeMatch]) - const onChange = useCallback((value: string): void => { - if (wellsTree) - setValue(getLabel(wellsTree, value)) - }, [wellsTree]) + const onChange = useCallback((value?: string): void => setValue(getLabel(wellsTree, value)), [wellsTree]) const onSelect = useCallback((value: RawValueType | LabelInValueType): void => { if (['number', 'string'].includes(typeof value))