GriffinJohnston / ldrs

Modern, tree-shakeable loader & spinner web components. Made with CSS, HTML and SVG. https://uiball.com/ldrs
MIT License
1.75k stars 54 forks source link

bad support for react #16

Closed swarajbachu closed 9 months ago

swarajbachu commented 11 months ago

I tried using both manual and auto and both doesnt seems to work on client side, in case we are using pages version of nextjs

I was using uiballs/loaders for my previous project and tried to find out it was replaced by good loaders but bad support

Screenshot 2023-11-26 at 5 45 05 PM
GriffinJohnston commented 11 months ago

Have you followed the guide for using LDRS with Next? https://github.com/GriffinJohnston/ldrs/blob/main/framework-guides.md#nextjs

swarajbachu commented 11 months ago

I did try it and it was giving me hydration errors

GriffinJohnston commented 11 months ago

How exactly have you used it in your project? I'll need to see some code to help troubleshoot.

swarajbachu commented 11 months ago

I am actually using it as main loader, so I am using server side fetching, which sometimes makes loading new pages slower, to prevent that I am using loader

  useEffect(() => {
    const start = () => {
      setLoading(true);
    };
    const end = () => {
      setLoading(false);
    };

    Router.events.on('routeChangeStart', start);
    Router.events.on('routeChangeComplete', end);
    Router.events.on('routeChangeError', end);

    return () => {
      Router.events.off('routeChangeStart', start);
      Router.events.off('routeChangeComplete', end);
      Router.events.off('routeChangeError', end);
    };
  }, []);

   {getLayout(loading ? <OwnLoader /> : <Component {...pageProps} />)}

function HourLoader() {
  useEffect(() => {
    async function getLoader() {
      const { hourglass } = await import('ldrs');
      hourglass.register();
    }
    void getLoader();
  }, []);
  return <l-hourglass color="black"/>;
}

function OwnLoader() {
  return (
    <div className="flex items-center justify-center h-screen">
      <HourLoader />
    </div>
  );
}
GriffinJohnston commented 11 months ago

I just spun up a quick demo app with create-next-app using the pages router and it built and ran just fine, no errors. I think I'll need to know more about how your project is structured to troubleshoot this. Do you happen to have this project up on Github, or even better a minimal reproduction of the issue I can reference?

GriffinJohnston commented 9 months ago

I'm closing this because I haven't heard back. Please feel free to submit a new issue with a reproduction somewhere if you're still having this problem!