MCPcopy Create free account
hub / github.com/DTStack/dt-react-component / useMergeOption

Function useMergeOption

src/useMergeOption/index.ts:10–26  ·  view source on GitHub ↗
(
    opt: MergeOption<T>,
    defaultOpt?: T
)

Source from the content-addressed store, hash-verified

8};
9
10export default function useMergeOption<T extends Record<string, any>>(
11 opt: MergeOption<T>,
12 defaultOpt?: T
13): ReturnMergeOption<T> {
14 return useMemo(() => {
15 if (typeof opt === 'object' && !!opt) {
16 return {
17 disabled: false,
18 options: { ...defaultOpt, ...opt },
19 };
20 }
21 return {
22 disabled: !opt,
23 options: <T>{ ...defaultOpt },
24 };
25 }, [opt]);
26}

Callers 4

BasicFunction · 0.85
index.test.tsFile · 0.85
FloatFunction · 0.85
InternalModalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected