fix(create): update lock state during render (#10782)

This commit is contained in:
shadcn
2026-05-26 23:56:45 +04:00
committed by GitHub
parent c824d6b78d
commit 3751fdfa4c

View File

@@ -24,15 +24,10 @@ const LocksContext = React.createContext<LocksContextValue | null>(null)
export function LocksProvider({ children }: { children: React.ReactNode }) {
const [locks, setLocks] = React.useState<Set<LockableParam>>(new Set())
const locksRef = React.useRef(locks)
React.useEffect(() => {
locksRef.current = locks
}, [locks])
// Stable callback — reads from ref so it doesn't change on every lock toggle.
const isLocked = React.useCallback(
(param: LockableParam) => locksRef.current.has(param),
[]
(param: LockableParam) => locks.has(param),
[locks]
)
const toggleLock = React.useCallback((param: LockableParam) => {