From 4e4b8f83e9d0e7958308a47531b88e08b504d70f Mon Sep 17 00:00:00 2001 From: Cole Lawrence Date: Thu, 16 Jun 2022 07:59:09 -0400 Subject: [PATCH] Disable usePresence flags by default (#226) --- theatre/studio/src/uiComponents/usePresence.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/theatre/studio/src/uiComponents/usePresence.tsx b/theatre/studio/src/uiComponents/usePresence.tsx index ceab033..4750223 100644 --- a/theatre/studio/src/uiComponents/usePresence.tsx +++ b/theatre/studio/src/uiComponents/usePresence.tsx @@ -21,7 +21,9 @@ export enum PresenceFlag { const undefinedD = prism(() => undefined) undefinedD.keepHot() // constant anyway... -function createPresenceContext(): InternalPresenceContext { +function createPresenceContext(options: { + enabled: boolean +}): InternalPresenceContext { const currentUserHoverItemB = new Box( undefined, ) @@ -61,6 +63,8 @@ function createPresenceContext(): InternalPresenceContext { } }, usePresenceFlag(itemKey) { + if (!options.enabled) return undefined + const focusD = useMemo(() => { if (!itemKey) return undefinedD // this is the thing being hovered @@ -127,10 +131,10 @@ type InternalPresenceContext = { } const presenceInternalCtx = React.createContext( - createPresenceContext(), + createPresenceContext({enabled: false}), ) export function ProvidePresenceRoot({children}: React.PropsWithChildren<{}>) { - const presence = useMemo(() => createPresenceContext(), []) + const presence = useMemo(() => createPresenceContext({enabled: false}), []) return React.createElement( presenceInternalCtx.Provider, {children, value: presence},