mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
(nextjs) added SSR Loader
This commit is contained in:
parent
d7def635e3
commit
41b26e7d69
5 changed files with 79 additions and 1 deletions
15
src/hooks/dom/useSSRLoadingIndicator.ts
Normal file
15
src/hooks/dom/useSSRLoadingIndicator.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
|
||||
import Router from 'next/router';
|
||||
|
||||
export const useSSRLoadingIndicator = () => {
|
||||
const [shown, setShown] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
Router.events.on('routeChangeStart', () => setShown(true));
|
||||
Router.events.on('routeChangeComplete', () => setShown(false));
|
||||
Router.events.on('routeChangeError', () => setShown(false));
|
||||
}, []);
|
||||
|
||||
return shown;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue