htmlstreamofficial / preline

Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.
https://preline.co
Other
4.9k stars 309 forks source link

Cannot read properties of undefined (reading 'getAttribute') In Next JS 14 #379

Closed princeajuzie7 closed 5 months ago

princeajuzie7 commented 5 months ago

my code has been working well then suddenly this error message started popping up.

"use client";

import { usePathname } from "next/navigation"; import { useEffect } from "react";

import { IStaticMethods } from "preline/preline"; declare global { interface Window { HSStaticMethods: IStaticMethods; } }

export function PrelineScript() { const path = usePathname();

useEffect(() => { const loadPreline = async () => { await import("preline/preline"); if (typeof window !== "undefined") {

    window.HSStaticMethods?.autoInit();
   }
};

loadPreline();

}, [path]);

return null; }

jahaganiev commented 5 months ago

Hey @princeajuzie7 - could you please provide working Stackblitz live demo and step by step details? You may fork the example demo here if needed.