ant-design/components/typography/hooks/useMergedConfig.ts

19 lines
440 B
TypeScript
Raw Normal View History

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