You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

18 lines
440 B

import * as React from 'react';
export default function useMergedConfig<Target>(
propConfig: any,
templateConfig?: Target,
): readonly [boolean, Target] {
return React.useMemo<readonly [boolean, Target]>(() => {
const support = !!propConfig;
return [
support,
{
...templateConfig,
...(support && typeof propConfig === 'object' ? propConfig : null),
},
] as const;
}, [propConfig]);
}