How I can uninit kaplay context? #597
-
Hi, I'm trying to add a small Kaplay game to my react project, the game is in react component, and I init kaplay in a separate file `import kaplay from "kaplay"; let k = null; export const initializeKaplay = () => { k = kaplay({ return k; export const getKaplay = () => k; export const destroyKaplay = () => { This context used in a different files, and when game component in unmounted, I use destroyKaplay func. How I can correctly uninit KAPLAY to avoid this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
At the moment is not possible quit KAPLAY without that hapening. Why do you need remove KAPLAY instance? |
Beta Was this translation helpful? Give feedback.
Best suggestion I have for the zillions of people that keep trying to stuff KAPLAY into a React component -- IT JUST DOESN'T WORK. DON'T USE REACT AND KAPLAY AT THE SAME TIME ON THE SAME PAGE IF IT'S A SINGLE PAGE APP (SPA). (although if it isn't a SPA, and going to a new page actually triggers a browser refresh, it should work).
If you must, load the kaplay game "fullscreen" in an
<iframe>
and then communicate with it usingpostMessage
.