LockOnMount
Acquires a record lock while mounted and releases it on unmount. Shows its children once the lock is held, a loading placeholder while requesting it, or the holder when another identity has it. Needs a realtime data provider with lock support.
Installation
pnpm dlx shadcn@latest add @chelone/lock-on-mountLoading preview…
Acquires a record lock while mounted and releases it on unmount. Shows its children once the lock is held, a loading placeholder while requesting it, or the holder when another identity has it. Needs a realtime data provider with lock support.
See the realtime guide for provider setup and usage.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Shown only while this component holds the lock. |
| id | Identifier | — | Defaults to the id of the record context. |
| identity | Identifier | — | Defaults to the auth provider's identity. |
| loading | ReactNode | — | Shown while the lock is requested. Defaults to a `Skeleton`. |
| lockedBy | (lock: Lock) => ReactNode | — | Shown when another identity holds the lock. Defaults to an `Alert` naming the holder. |
| meta | Record<string, unknown> | — | |
| onLockError | (error: Error) => void | — | Called with a failed lock or release. A new function every render never relocks. |
| resource | string | — | Defaults to the resource context. |