You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...
export { AlertTitle } from "./alert-title"
export type { AlertTitleProps } from "./alert-title"
export * as Alert from "./namespace"
and then in namespace.ts -
export { AlertTitle as Title } from "./alert-title"
export type { AlertTitleProps as TitleProps } from "./alert-title"
So if I understand that correctly, I can do all of the following -
import { Alert } from '@chakra-ui/react'
...
<Alert.Title>...</Alert.Title>
and
import { Alert } from '@chakra-ui/react'
...
const { Title } = Alert
...
<Title>...</Title>
and also
import { AlertTitle } from '@chakra-ui/react'
...
<AlertTitle>...</AlertTitle>
Are there any guidance as when to use of these over the other? Any pros or cons to any of these? Or are they all the exact same, just down to personal preference?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
From looking at https://github.com/chakra-ui/chakra-ui/blob/main/MIGRATION.md#namespace-components and also digging through the v3 source code, there's a movement towards namespacing components, but I notice the components are also exposed individually -
e.g.
and then in
namespace.ts
-So if I understand that correctly, I can do all of the following -
and
and also
Are there any guidance as when to use of these over the other? Any pros or cons to any of these? Or are they all the exact same, just down to personal preference?
Beta Was this translation helpful? Give feedback.
All reactions