create-icon-loader.tsx — ui Source File
Architecture documentation for create-icon-loader.tsx, a tsx file in the ui codebase. 2 imports, 5 dependents.
Entity Profile
Dependency Diagram
graph LR 8f16ccd8_8171_26c3_e15a_50ba9fc94180["create-icon-loader.tsx"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] 8f16ccd8_8171_26c3_e15a_50ba9fc94180 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 614a3ef5_2f09_8b4c_c7b8_666db5a9ce32["react"] 8f16ccd8_8171_26c3_e15a_50ba9fc94180 --> 614a3ef5_2f09_8b4c_c7b8_666db5a9ce32 11cf1d17_0c2b_4b87_5398_05c4f9fdd207["icon-hugeicons.tsx"] 11cf1d17_0c2b_4b87_5398_05c4f9fdd207 --> 8f16ccd8_8171_26c3_e15a_50ba9fc94180 c69cb0dc_6bb6_7af2_8d84_8d233196aedc["icon-lucide.tsx"] c69cb0dc_6bb6_7af2_8d84_8d233196aedc --> 8f16ccd8_8171_26c3_e15a_50ba9fc94180 b77aa154_b43d_cabc_6aa3_5f34f1eaf742["icon-phosphor.tsx"] b77aa154_b43d_cabc_6aa3_5f34f1eaf742 --> 8f16ccd8_8171_26c3_e15a_50ba9fc94180 75142f09_d223_d760_2f0f_7f9c9dddcdb1["icon-remixicon.tsx"] 75142f09_d223_d760_2f0f_7f9c9dddcdb1 --> 8f16ccd8_8171_26c3_e15a_50ba9fc94180 96bb2dcc_2f80_56f2_59c3_089fcf4696ee["icon-tabler.tsx"] 96bb2dcc_2f80_56f2_59c3_089fcf4696ee --> 8f16ccd8_8171_26c3_e15a_50ba9fc94180 style 8f16ccd8_8171_26c3_e15a_50ba9fc94180 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/* eslint-disable @typescript-eslint/no-explicit-any */
"use client"
import { use } from "react"
import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react"
const iconPromiseCaches = new Map<string, Map<string, Promise<any>>>()
function getCache(libraryName: string) {
if (!iconPromiseCaches.has(libraryName)) {
iconPromiseCaches.set(libraryName, new Map())
}
return iconPromiseCaches.get(libraryName)!
}
function isIconData(data: any): data is IconSvgElement {
return Array.isArray(data)
}
export function createIconLoader(libraryName: string) {
const cache = getCache(libraryName)
return function IconLoader({
name,
strokeWidth = 2,
...props
}: {
name: string
} & React.ComponentProps<"svg">) {
if (!cache.has(name)) {
const promise = import(`./__${libraryName}__`).then((mod) => {
const icon = mod[name as keyof typeof mod]
return icon || null
})
cache.set(name, promise)
}
const iconData = use(cache.get(name)!)
if (!iconData) {
return null
}
if (isIconData(iconData)) {
return <HugeiconsIcon icon={iconData} strokeWidth={2} {...props} />
}
const IconComponent = iconData
return <IconComponent {...props} />
}
}
Domain
Subdomains
Functions
Dependencies
- react
- react
Imported By
Source
Frequently Asked Questions
What does create-icon-loader.tsx do?
create-icon-loader.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, ChartRegistry subdomain.
What functions are defined in create-icon-loader.tsx?
create-icon-loader.tsx defines 3 function(s): createIconLoader, getCache, isIconData.
What does create-icon-loader.tsx depend on?
create-icon-loader.tsx imports 2 module(s): react, react.
What files import create-icon-loader.tsx?
create-icon-loader.tsx is imported by 5 file(s): icon-hugeicons.tsx, icon-lucide.tsx, icon-phosphor.tsx, icon-remixicon.tsx, icon-tabler.tsx.
Where is create-icon-loader.tsx in the architecture?
create-icon-loader.tsx is located at apps/v4/registry/icons/create-icon-loader.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: apps/v4/registry/icons).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free