Close active elems (react-query refactor) (#1926)
* Refactor closeAny and closeAllActiveElements * Add close lightbox * Switch to hooks * Fixes
This commit is contained in:
parent
0de8d40981
commit
a84b2f9f2f
9 changed files with 101 additions and 66 deletions
|
@ -31,10 +31,10 @@ const LightboxContext = React.createContext<{
|
|||
|
||||
const LightboxControlContext = React.createContext<{
|
||||
openLightbox: (lightbox: Lightbox) => void
|
||||
closeLightbox: () => void
|
||||
closeLightbox: () => boolean
|
||||
}>({
|
||||
openLightbox: () => {},
|
||||
closeLightbox: () => {},
|
||||
closeLightbox: () => false,
|
||||
})
|
||||
|
||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
|
@ -50,8 +50,10 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||
)
|
||||
|
||||
const closeLightbox = React.useCallback(() => {
|
||||
let wasActive = !!activeLightbox
|
||||
setActiveLightbox(null)
|
||||
}, [setActiveLightbox])
|
||||
return wasActive
|
||||
}, [setActiveLightbox, activeLightbox])
|
||||
|
||||
const state = React.useMemo(
|
||||
() => ({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue