ant-design/components/_util/getRenderPropValue.ts

18 lines
334 B
TypeScript
Raw Normal View History

import type * as React from 'react';
export type RenderFunction = () => React.ReactNode;
export const getRenderPropValue = (
propValue?: React.ReactNode | RenderFunction,
): React.ReactNode => {
if (!propValue) {
return null;
}
2022-11-09 17:36:49 +08:00
if (typeof propValue === 'function') {
return propValue();
}
return propValue;
};