The useMapProviderContext hook in its current form is mostly un-usable because the context provider component for this hook is not mounted at a high-enough level where custom components will be a descendant component. These custom components will either be siblings with the context provider or their parent components are siblings, so the hook when called from a custom component will be a (default, un-initialized) viewer instance.
To fix this, we need to mount this context provider component at a higher level, preferably as a direct child of the root <App> component (or <AppInner>). However, relocating mount point is probably not trivial as the context provider is tightly coupled to init-ing the OpenLayers against a physical DOM element.
An alternative solution could be to leverage React portals so that we don't require context provider and context consumer with direct physical DOM parentage of their respective components.
The
useMapProviderContext
hook in its current form is mostly un-usable because the context provider component for this hook is not mounted at a high-enough level where custom components will be a descendant component. These custom components will either be siblings with the context provider or their parent components are siblings, so the hook when called from a custom component will be a (default, un-initialized) viewer instance.To fix this, we need to mount this context provider component at a higher level, preferably as a direct child of the root
<App>
component (or<AppInner>
). However, relocating mount point is probably not trivial as the context provider is tightly coupled to init-ing the OpenLayers against a physical DOM element.An alternative solution could be to leverage React portals so that we don't require context provider and context consumer with direct physical DOM parentage of their respective components.