ant-design/components/_util/getRenderPropValue.ts
Gibson C 428f743b50
feat: Support render props for <Popover/> and <Popconfirm/> (#22034)
* feat: Support render props for <Popover/>

* feat: Support render props for <Popconfirm/>

* docs: Update Popconfirm docs
2020-03-10 13:57:02 +08:00

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;
};