diff options
author | dan <dan.abramov@gmail.com> | 2023-11-17 06:18:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-16 22:18:37 -0800 |
commit | a8aed2c38e1b45d3f816b79fdd42bedfc7918319 (patch) | |
tree | de90e5ac77b0e2bb7c2f8d39f22e239a94ceeb7b /src/state/lightbox.tsx | |
parent | a10adf89084a179892530ce6af4dffa12ae02795 (diff) | |
download | voidsky-a8aed2c38e1b45d3f816b79fdd42bedfc7918319.tar.zst |
Use non-reactive callbacks for some methods (#1948)
* Use non-reactive callbacks for some methods * Remove unnecessary state * Use non-reactive callbacks for modals
Diffstat (limited to 'src/state/lightbox.tsx')
-rw-r--r-- | src/state/lightbox.tsx | 14 |
1 files changed, 6 insertions, 8 deletions
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( () => ({ |