I'm implementing h5p's with reactjs, I'm able to play the h5p player, however i'm unable to view the events with the externalDispatcher.on("xAPI", (event)... command.
How can i log the event of a h5p in reactjs
Error message: Cannot read properties of undefined (reading 'on')
import { H5P } from "h5p-standalone";
import { useEffect } from "react";
export default function App() {
useEffect(() => {
const el = document.getElementById("h5p-container");
const options = {
h5pJsonPath: "/h5p/pygame",
frameJs: "/assets/frame.bundle.js",
frameCss: "/assets/styles/h5p.css"
};
const needAsync = async () => {
await new H5P(el, options).then((res) => {
H5P.externalDispatcher.on("xAPI", (event) => {
console.log(event);
});
});
};
needAsync();
}, []);
return <></>;
}