DenoDDeno
Powered by
wedmaniacW
Denoβ€’3y agoβ€’
12 replies
wedmaniac

How can I make sure the code gets run on the client-side??!

import { useEffect, useState } from "preact/hooks";

export default function Callback() {
    useEffect(() => {
        const hashParam = window.location.hash.substring(1);
        console.log(`Param: ${hashParam}`);
       
    }, []);

    return (
        <div>
            ....
        </div>
    );
}
import { useEffect, useState } from "preact/hooks";

export default function Callback() {
    useEffect(() => {
        const hashParam = window.location.hash.substring(1);
        console.log(`Param: ${hashParam}`);
       
    }, []);

    return (
        <div>
            ....
        </div>
    );
}


I would assume that the code is getting fired on the server side and that the error occurs when it is trying to access the window. Thank you in advance!
image.png
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

How can I do server sent events on the client side in deno?
Bustin BaseBBustin Base / help
3y ago
How can i make VS Code extensions using Deno?
Master OogwayMMaster Oogway / help
2y ago
How do I make Deno run code when it is closed out on Windows
NiteruxNNiterux / help
16mo ago
client side JS
dan.the.discloserDdan.the.discloser / help
3y ago