UNPKG

@rxflow/base

Version:

BaseFlow - 核心 Flow 组件库

31 lines (29 loc) 1.06 kB
/** * @author: yanxianliang * @date: 2025-10-16 16:12 * @modified:2025/10/16 16:12 by yanxianliang * @desc: * * Copyright (c) 2025 by yanxianliang, All Rights Reserved. */ import { useSelector } from "../state/useSelector"; export function usePropsSelector(selector) { return useSelector(function (state) { var props = state.props; return selector ? selector(props) : props; }); } // // export function usePropsSelector<GraphProps = IBaseFlowProps>(): GraphProps; // export function usePropsSelector<GraphProps = IBaseFlowProps, U = unknown>(selector: (state: ExtractState<StoreApi<GraphProps>>) => U): U; // // export function usePropsSelector< // GraphProps = IBaseFlowProps, // U = any, // >(selector?: ExtractState<StoreApi<GraphProps>>) { // const useStore = useContext(PropsContext)?.useStore as UseBoundStore<StoreApi<GraphProps>>; // if (!useStore) { // throw new Error("usePropsSelector must be used within PropsProvider"); // } // return useStore(selector as (state: ExtractState<StoreApi<GraphProps>>) => U); // }