In order to use reveal.js in Deno Fresh, I use this code on island:
import { useEffect } from "https://esm.sh/v128/preact@10.19.6/hooks/src/index.js";
import Reveal from '../reveal/js/index.js';
export default function Island() {
useEffect(()=> {
setDeck(new Reveal());
deck.initialize();
})
return <>Text</>
}
I think this is the correct way to use the hook, but I get this error:
An error occurred during route handling or page rendering.
3 |
4 | export default function Island() {
> 5 | useEffect(()=> {
| ^
6 | newFunction();
7 |
8 | function newFunction() {
TypeError: Cannot read properties of null (reading '__hooks')
at s (https://esm.sh/stable/preact@10.19.6/denonext/hooks/src.js:2:1339)
at G (https://esm.sh/stable/preact@10.19.6/denonext/hooks/src.js:2:2385)
at Object.Island (file:///D:/Programming/Test/fresh-project/islands/Island.jsx:5:3)
at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:3237)
at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:2543)
at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:3802)
at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:3802)
at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:3802)
at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:3802)
at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:3802)
What happens?
You're mixing built, production code and source code (/hooks/src/...
), which you cannot do.
Use the built hooks output: https://esm.sh/v128/preact@10.19.6/hooks