#TypeError: useContext is not a function or its return value is not iterable
4 messages · Page 1 of 1 (latest)
The code composing together the components is external to this file.
Assuming everything else is working:
ModalPUp is undefined until the ModalPopUp executes. If any of the other Modal* components run beforehand ModalPUp will still be undefined.
Yeas everything else is working. What should I do for that?
In broad strokes:
let modeld = undefined;
const showhide = [
{
show() {
if (modeld && modeld.isHidden()) {
modeld.show();
}
},
hide() {
if (modeld && modeld.isVisible()) {
modeld.hide();
}
},
},
];
const ModelPUp = createContext(showhide);
export default function ModalPopUp(props) {
// …
onMount(() => {
modeld = new Modal(modalElement, modalOptions, instanceOptions);
});
onCleanup(() => {
modeld = undefined;
});
return <>{/* … */}</>;
}