Home / Function/ LocksProvider() — ui Function Reference

LocksProvider() — ui Function Reference

Architecture documentation for the LocksProvider() function in use-locks.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  2a1ea96a_3bb0_840f_6916_7fc4c319c98b["LocksProvider()"]
  ecaf6550_2376_5851_f8c3_97465aac7be4["use-locks.tsx"]
  2a1ea96a_3bb0_840f_6916_7fc4c319c98b -->|defined in| ecaf6550_2376_5851_f8c3_97465aac7be4
  style 2a1ea96a_3bb0_840f_6916_7fc4c319c98b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/app/(create)/hooks/use-locks.tsx lines 23–49

export function LocksProvider({ children }: { children: React.ReactNode }) {
  const [locks, setLocks] = React.useState<Set<LockableParam>>(new Set())

  const isLocked = React.useCallback(
    (param: LockableParam) => locks.has(param),
    [locks]
  )

  const toggleLock = React.useCallback((param: LockableParam) => {
    setLocks((prev) => {
      const next = new Set(prev)
      if (next.has(param)) {
        next.delete(param)
      } else {
        next.add(param)
      }
      return next
    })
  }, [])

  const value = React.useMemo(
    () => ({ locks, isLocked, toggleLock }),
    [locks, isLocked, toggleLock]
  )

  return <LocksContext value={value}>{children}</LocksContext>
}

Subdomains

Frequently Asked Questions

What does LocksProvider() do?
LocksProvider() is a function in the ui codebase, defined in apps/v4/app/(create)/hooks/use-locks.tsx.
Where is LocksProvider() defined?
LocksProvider() is defined in apps/v4/app/(create)/hooks/use-locks.tsx at line 23.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free