@lomray/vite-ssr-boost 1.0.0-beta.32 → 1.0.0-beta.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
interface IScrollToTop {
|
|
3
|
+
shouldReloadReset?: boolean;
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
6
|
* Scroll page to top on every pathname (url) change
|
|
4
7
|
* @constructor
|
|
5
8
|
*/
|
|
6
|
-
declare const ScrollToTop: FC
|
|
9
|
+
declare const ScrollToTop: FC<IScrollToTop>;
|
|
7
10
|
export { ScrollToTop as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useEffect as o}from"react";import{useLocation as
|
|
1
|
+
import{useRef as r,useEffect as o}from"react";import{useLocation as t}from"react-router-dom";const e=({shouldReloadReset:e=!1})=>{const{pathname:n}=t(),a=r(n);return o((()=>{(e||a.current!==n)&&(a.current=n,window.scrollTo(0,0))}),[n]),null};export{e as default};
|
|
2
2
|
//# sourceMappingURL=scroll-to-top.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll-to-top.js","sources":["../../src/components/scroll-to-top.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useEffect } from 'react';\nimport { useLocation } from 'react-router-dom';\n\n/**\n * Scroll page to top on every pathname (url) change\n * @constructor\n */\nconst ScrollToTop: FC = () => {\n const { pathname } = useLocation();\n\n useEffect(() => {\n window.scrollTo(0, 0);\n }, [pathname]);\n\n return null;\n};\n\nexport default ScrollToTop;\n"],"names":["ScrollToTop","pathname","useLocation","useEffect","window","scrollTo"],"mappings":"
|
|
1
|
+
{"version":3,"file":"scroll-to-top.js","sources":["../../src/components/scroll-to-top.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useEffect, useRef } from 'react';\nimport { useLocation } from 'react-router-dom';\n\ninterface IScrollToTop {\n shouldReloadReset?: boolean;\n}\n\n/**\n * Scroll page to top on every pathname (url) change\n * @constructor\n */\nconst ScrollToTop: FC<IScrollToTop> = ({ shouldReloadReset = false }) => {\n const { pathname } = useLocation();\n const prev = useRef(pathname);\n\n useEffect(() => {\n if (!shouldReloadReset && prev.current === pathname) {\n return;\n }\n\n prev.current = pathname;\n window.scrollTo(0, 0);\n }, [pathname]);\n\n return null;\n};\n\nexport default ScrollToTop;\n"],"names":["ScrollToTop","shouldReloadReset","pathname","useLocation","prev","useRef","useEffect","current","window","scrollTo"],"mappings":"6FAYM,MAAAA,EAAgC,EAAGC,qBAAoB,MAC3D,MAAMC,SAAEA,GAAaC,IACfC,EAAOC,EAAOH,GAWpB,OATAI,GAAU,MACHL,GAAqBG,EAAKG,UAAYL,KAI3CE,EAAKG,QAAUL,EACfM,OAAOC,SAAS,EAAG,GAAE,GACpB,CAACP,IAEG,IAAI"}
|