-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Javascript Functionality are not working in components (Next.JS) #261
Comments
Here's my "use client";
import HSAccordion from "@preline/accordion";
import { usePathname } from "next/navigation";
import { HSDropdown } from "preline/preline";
import { useEffect } from "react";
export default function PrelineLoader() {
const path = usePathname();
useEffect(() => {
import("preline/preline");
}, []);
useEffect(() => {
setTimeout(() => {
HSAccordion.autoInit();
HSDropdown.autoInit();
}, 100)
}, [path])
return <></>
} It's working for me. |
Thank you, but it is not working still the same issue |
Sometimes this setTimeout is too short and the preline JS isn't imported yet. Obviously we don't want to increase the timeout (in fact, we technically don't want it at all). There must be a better way to initialize preline without depending on the useEffect & setTimeout... Sorry I don't have a solution but this error is visible more commonly when generating lighthouse reports on pages that have preline JS instantiated like this. |
Coming back with a solution here, I put it inside its own issue: #270
|
Hey folks, seems the issue has been addressed by the community. We've also added Preline JavaScript page with some explanation how Preline JavaScript works. https://preline.co/docs/preline-javascript.html Cheers! |
Assalomu aleykum. Oka ishamitida baribir shu. Misol birorta dropdown birmarta ishlagandan kein. Boshqa pagega utib qaytib kelmaguncha ishlamayapti. Shunga nima qilsak boladi? |
I cannot use interact with components which uses plugins like
select
,stepper
etcHere's my configurations (I followed official documentation)
PrelineScript.tsx
tailwind.config.ts
Any help are appreciated
The text was updated successfully, but these errors were encountered: