From a8aed2c38e1b45d3f816b79fdd42bedfc7918319 Mon Sep 17 00:00:00 2001
From: dan <dan.abramov@gmail.com>
Date: Fri, 17 Nov 2023 06:18:37 +0000
Subject: Use non-reactive callbacks for some methods  (#1948)

* Use non-reactive callbacks for some methods

* Remove unnecessary state

* Use non-reactive callbacks for modals
---
 src/state/lightbox.tsx | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

(limited to 'src/state/lightbox.tsx')

diff --git a/src/state/lightbox.tsx b/src/state/lightbox.tsx
index d5528ac28..e3bddaee0 100644
--- a/src/state/lightbox.tsx
+++ b/src/state/lightbox.tsx
@@ -1,5 +1,6 @@
 import React from 'react'
 import {AppBskyActorDefs} from '@atproto/api'
+import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
 
 interface Lightbox {
   name: string
@@ -42,18 +43,15 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
     null,
   )
 
-  const openLightbox = React.useCallback(
-    (lightbox: Lightbox) => {
-      setActiveLightbox(lightbox)
-    },
-    [setActiveLightbox],
-  )
+  const openLightbox = useNonReactiveCallback((lightbox: Lightbox) => {
+    setActiveLightbox(lightbox)
+  })
 
-  const closeLightbox = React.useCallback(() => {
+  const closeLightbox = useNonReactiveCallback(() => {
     let wasActive = !!activeLightbox
     setActiveLightbox(null)
     return wasActive
-  }, [setActiveLightbox, activeLightbox])
+  })
 
   const state = React.useMemo(
     () => ({
-- 
cgit 1.4.1

