Download ant-design/components/_util/convertToTooltipProps.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 481 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/ant-design/components/_util/convertToTooltipProps.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/ant-design/components/_util/convertToTooltipProps.ts
-
curl -L -o convertToTooltipProps.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/ant-design/components/_util/convertToTooltipProps.ts
481 Bytes
| import type { ReactNode } from 'react'; | |
| import { isValidElement } from 'react'; | |
| import type { TooltipProps } from '../tooltip'; | |
| function convertToTooltipProps<P extends TooltipProps>(tooltip: P | ReactNode): P | null { | |
| // isNil | |
| if (tooltip === undefined || tooltip === null) { | |
| return null; | |
| } | |
| if (typeof tooltip === 'object' && !isValidElement(tooltip)) { | |
| return tooltip as P; | |
| } | |
| return { | |
| title: tooltip, | |
| } as P; | |
| } | |
| export default convertToTooltipProps; | |