react-material-overlay
Version:
A fully featured Material UI implementation of overlays like modals, alert dialogs, lightboxes, and bottom sheets featuring easy stack management and browser history integration
17 lines (12 loc) • 587 B
text/typescript
import React from 'react';
import { isLightboxActive, registerLightboxContainer } from '../../core/Lightbox/store';
import { ILightboxContainerProps } from '../../core/Lightbox/types';
export default function useLightboxContainer(props: ILightboxContainerProps) {
const { subscribe, getSnapshot, setDefaultOptions } = React.useRef(registerLightboxContainer(props)).current;
setDefaultOptions(props.defaultOptions);
const snapshot = React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
return {
lightboxList: snapshot || [],
isLightboxActive
};
}