component-wrapper.tsx — ui Source File
Architecture documentation for component-wrapper.tsx, a tsx file in the ui codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR e45a2200_2ccc_c5a6_144d_516890bb99cb["component-wrapper.tsx"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] e45a2200_2ccc_c5a6_144d_516890bb99cb --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 7758fdd8_25c1_a333_03ce_5e171102a1ec["utils"] e45a2200_2ccc_c5a6_144d_516890bb99cb --> 7758fdd8_25c1_a333_03ce_5e171102a1ec style e45a2200_2ccc_c5a6_144d_516890bb99cb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"use client"
import * as React from "react"
import { cn } from "@/registry/new-york-v4/lib/utils"
export function ComponentWrapper({
className,
name,
children,
...props
}: React.ComponentPropsWithoutRef<"div"> & { name: string }) {
return (
<ComponentErrorBoundary name={name}>
<div
id={name}
data-name={name.toLowerCase()}
className={cn(
"flex w-full scroll-mt-16 flex-col rounded-lg border",
className
)}
{...props}
>
<div className="border-b px-4 py-3">
<div className="text-sm font-medium">{getComponentName(name)}</div>
</div>
<div className="flex flex-1 items-center gap-2 p-4">{children}</div>
</div>
</ComponentErrorBoundary>
)
}
class ComponentErrorBoundary extends React.Component<
{ children: React.ReactNode; name: string },
{ hasError: boolean }
> {
constructor(props: { children: React.ReactNode; name: string }) {
super(props)
this.state = { hasError: false }
}
static getDerivedStateFromError() {
return { hasError: true }
}
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
console.error(`Error in component ${this.props.name}:`, error, errorInfo)
}
render() {
if (this.state.hasError) {
return (
<div className="p-4 text-red-500">
Something went wrong in component: {this.props.name}
</div>
)
}
return this.props.children
}
}
function getComponentName(name: string) {
// convert kebab-case to title case
return name.replace(/-/g, " ").replace(/\b\w/g, (char) => char.toUpperCase())
}
Domain
Subdomains
Functions
Classes
Dependencies
- react
- utils
Source
Frequently Asked Questions
What does component-wrapper.tsx do?
component-wrapper.tsx is a source file in the ui codebase, written in tsx. It belongs to the Internationalization domain, RTLLayout subdomain.
What functions are defined in component-wrapper.tsx?
component-wrapper.tsx defines 2 function(s): ComponentWrapper, getComponentName.
What does component-wrapper.tsx depend on?
component-wrapper.tsx imports 2 module(s): react, utils.
Where is component-wrapper.tsx in the architecture?
component-wrapper.tsx is located at apps/v4/components/component-wrapper.tsx (domain: Internationalization, subdomain: RTLLayout, directory: apps/v4/components).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free