MCPcopy Create free account
hub / github.com/alibaba/lowcode-engine / createIcon

Function createIcon

packages/utils/src/create-icon.tsx:9–40  ·  view source on GitHub ↗
(
    icon?: IPublicTypeIconType | null,
    props?: Record<string, unknown>,
  )

Source from the content-addressed store, hash-verified

7const URL_RE = /^(https?:)\/\//i;
8
9export function createIcon(
10 icon?: IPublicTypeIconType | null,
11 props?: Record<string, unknown>,
12 ): ReactNode {
13 if (!icon) {
14 return null;
15 }
16 if (isESModule(icon)) {
17 icon = icon.default;
18 }
19 if (typeof icon === 'string') {
20 if (URL_RE.test(icon)) {
21 return createElement('img', {
22 src: icon,
23 class: props?.className,
24 ...props,
25 });
26 }
27 return <Icon type={icon} {...props} />;
28 }
29 if (isValidElement(icon)) {
30 return cloneElement(icon, { ...props });
31 }
32 if (isReactComponent(icon)) {
33 return createElement(icon, {
34 class: props?.className,
35 ...props,
36 });
37 }
38
39 return <Icon {...icon} {...props} />;
40}

Callers 4

renderMethod · 0.85
createActionFunction · 0.85
renderMethod · 0.85
renderBreadcrumbMethod · 0.85

Calls 2

isESModuleFunction · 0.90
isReactComponentFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…