mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-29 05:29:37 +08:00
19 lines
389 B
TypeScript
19 lines
389 B
TypeScript
|
import React from 'react';
|
||
|
|
||
|
export type RenderFunction = () => React.ReactNode;
|
||
|
|
||
|
export const getRenderPropValue = (
|
||
|
propValue?: React.ReactNode | RenderFunction,
|
||
|
): React.ReactNode => {
|
||
|
if (!propValue) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
const isRenderFunction = typeof propValue === 'function';
|
||
|
if (isRenderFunction) {
|
||
|
return (propValue as RenderFunction)();
|
||
|
}
|
||
|
|
||
|
return propValue;
|
||
|
};
|