presence
diceui-base/presenceFreeComponent
diceui/base publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/base-vega/presence.jsonSource
1"use client";23import * as React from "react";45interface PresenceProps {6 children:7 | React.ReactElement8 | ((props: { present: boolean }) => React.ReactElement);9 present: boolean;10}1112function Presence({ children, present }: PresenceProps) {13 const [mounted, setMounted] = React.useState(present);14 const prevPresentRef = React.useRef(present);1516 React.useEffect(() => {17 const wasMounted = prevPresentRef.current;18 const hasMounted = present;1920 if (hasMounted) {21 setMounted(true);22 } else if (wasMounted && !hasMounted) {23 setMounted(false);24 }2526 prevPresentRef.current = present;27 }, [present]);2829 if (!mounted) return null;3031 return typeof children === "function"32 ? children({ present: mounted && present })33 : children;34}3536export { Presence };
What it pulls in
npm packages
Files it writes
More from diceui/base
All 192 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| action-baraction-bar | diceui/base | Components | Free | 1 dep | |
| angle-sliderangle-slider | diceui/base | Components | Free | 1 dep · 3 files | |
| avatar-groupavatar-group | diceui/base | Components | Free | 1 dep | |
| badge-overflowbadge-overflow | diceui/base | Components | Free | 1 dep · 2 files | |
| bannerbanner | diceui/base | Components | Free | 1 dep | |
| circular-progresscircular-progress | diceui/base | Components | Free | 1 dep | |
| client-onlyclient-only | diceui/base | Components | Free | no deps | |
| color-pickercolor-picker | diceui/base | Components | Free | 1 dep · 2 files |
