export const useOpenSeadragon = () => React.useContext(Context);
-export const Provider = React.forwardRef(({ children }, ref) => {
+export const Provider = ({ children, containerRef }) => {
const { activeMap } = useParams();
const navigate = useNavigate();
const [searchParams, setSearchParams] = useSearchParams();
}, [searchParams, viewer]);
React.useEffect(() => {
- if (!ref.current) return;
+ if (!containerRef.current) return;
const v = OpenSeadragon({
- element: ref.current,
+ element: containerRef.current,
preserveViewport: true,
sequenceMode: true,
showNavigator: true,
return () => {
v.destroy();
};
- }, [ref.current]);
+ }, [containerRef.current]);
React.useEffect(() => {
if (!viewer) return;
return <Context.Provider value={{ activeMap, pins, setActiveMap, storePosition, viewer }}>
{children}
</Context.Provider>;
-});
+};
Provider.displayName = 'OpenSeadragonProvider';
Provider.propTypes = {
children: PropTypes.node,
+ containerRef: PropTypes.shape({ current: PropTypes.instanceOf(Element) }),
};
export default Provider;
<meta name="description" content={t('map.description')} />
</Helmet>
<CanonicalLinks base={`/map/${activeMap}`} />
- <OpenSeadragon ref={container}>
+ <OpenSeadragon containerRef={container}>
<div className="d-flex align-items-start justify-content-between">
<h1>{t('map.heading')} - {t(`map.${activeMap}Long`)}</h1>
<Buttons setUWOverlay={setUWOverlay} uwOverlay={uwOverlay} />