Use non-reactive callbacks for some methods (#1948)
* Use non-reactive callbacks for some methods * Remove unnecessary state * Use non-reactive callbacks for modals
This commit is contained in:
parent
a10adf8908
commit
a8aed2c38e
3 changed files with 34 additions and 39 deletions
|
@ -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(
|
||||
() => ({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue