react-router-scroll-to-top 1.2.0 → 1.3.0
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.
- package/README.md +6 -8
- package/index.d.ts +6 -14
- package/lib/index.js +1 -2
- package/package.json +62 -65
- package/lib/index.js.LICENSE.txt +0 -9
package/README.md
CHANGED
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
[](https://github.com/dimazuien/react-router-scroll-to-top/issues)
|
|
7
7
|
[](https://github.com/dimazuien/react-router-scroll-to-top/pulls)
|
|
8
8
|
[](https://github.com/dimazuien/react-router-scroll-to-top/stargazers)
|
|
9
|
-

|
|
10
|
+

|
|
11
11
|
|
|
12
|
-
ScrollToTop is a React component that scrolls to the top of
|
|
12
|
+
ScrollToTop is a React component that scrolls to the top of the page when the location changes. It's for apps that use React Router 5.1 to 7 in declarative mode, with `<BrowserRouter>`, where React Router has no built-in scroll handling.
|
|
13
|
+
|
|
14
|
+
If your app uses a data router (`createBrowserRouter` with `<RouterProvider>`) or framework mode, use React Router's [`<ScrollRestoration>`](https://reactrouter.com/7.18.7/api/components/ScrollRestoration) instead. It also restores the scroll position when users go back or forward.
|
|
13
15
|
|
|
14
16
|
## Usage
|
|
15
17
|
|
|
@@ -23,13 +25,9 @@ import { ScrollToTop } from 'react-router-scroll-to-top';
|
|
|
23
25
|
const App = () => (
|
|
24
26
|
<BrowserRouter>
|
|
25
27
|
<ScrollToTop />
|
|
26
|
-
<
|
|
28
|
+
<Routes>{/* routes */}</Routes>
|
|
27
29
|
</BrowserRouter>
|
|
28
30
|
);
|
|
29
31
|
```
|
|
30
32
|
|
|
31
33
|
Read [the documentation](https://github.com/dimazuien/react-router-scroll-to-top/blob/main/docs/index.md) for more details. You can also play with a [demo](https://codesandbox.io/s/react-router-scroll-to-top-n1mg3).
|
|
32
|
-
|
|
33
|
-
## Support
|
|
34
|
-
|
|
35
|
-
If you like this package and want to support it, you can fund us on [Patreon](https://www.patreon.com/dimazuien)
|
package/index.d.ts
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
declare module 'react-router-scroll-to-top/src/ScrollToTop' {
|
|
2
|
-
import { ReactNode } from 'react';
|
|
1
|
+
declare module 'react-router-scroll-to-top/src/ScrollToTop/index' {
|
|
2
|
+
import { ReactElement, ReactNode } from 'react';
|
|
3
3
|
type Props = Readonly<{
|
|
4
4
|
children?: ReactNode;
|
|
5
5
|
}>;
|
|
6
|
-
function ScrollToTop({ children }: Props):
|
|
6
|
+
function ScrollToTop({ children }: Props): ReactElement;
|
|
7
7
|
export default ScrollToTop;
|
|
8
8
|
|
|
9
9
|
}
|
|
10
10
|
declare module 'react-router-scroll-to-top/src/index' {
|
|
11
|
-
export { default as ScrollToTop } from 'react-router-scroll-to-top/src/ScrollToTop';
|
|
12
|
-
export { default as useScrollToTop } from 'react-router-scroll-to-top/src/useScrollToTop';
|
|
11
|
+
export { default as ScrollToTop } from 'react-router-scroll-to-top/src/ScrollToTop/index';
|
|
12
|
+
export { default as useScrollToTop } from 'react-router-scroll-to-top/src/useScrollToTop/index';
|
|
13
13
|
|
|
14
14
|
}
|
|
15
|
-
declare module 'react-router-scroll-to-top/src/useScrollToTop' {
|
|
15
|
+
declare module 'react-router-scroll-to-top/src/useScrollToTop/index' {
|
|
16
16
|
const useScrollToTop: () => void;
|
|
17
17
|
export default useScrollToTop;
|
|
18
18
|
|
|
19
|
-
}
|
|
20
|
-
declare module 'react-router-scroll-to-top/tests/ScrollToTop.test' {
|
|
21
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
declare module 'react-router-scroll-to-top/tests/useScrollToTop.test' {
|
|
25
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
26
|
-
|
|
27
19
|
}
|
|
28
20
|
declare module 'react-router-scroll-to-top' {
|
|
29
21
|
import main = require('react-router-scroll-to-top/src/index');
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["react-router-scroll-to-top"]=r():e["react-router-scroll-to-top"]=r()}(self,(function(){return function(){"use strict";var e={44:function(e,r,o){var t=o(497),n=Symbol.for("react.element"),u=Symbol.for("react.fragment"),f=Object.prototype.hasOwnProperty,c=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};r.Fragment=u,r.jsx=function(e,r,o){var t,u={},l=null,a=null;for(t in void 0!==o&&(l=""+o),void 0!==r.key&&(l=""+r.key),void 0!==r.ref&&(a=r.ref),r)f.call(r,t)&&!i.hasOwnProperty(t)&&(u[t]=r[t]);if(e&&e.defaultProps)for(t in r=e.defaultProps)void 0===u[t]&&(u[t]=r[t]);return{$$typeof:n,type:e,key:l,ref:a,props:u,_owner:c.current}}},598:function(e,r,o){e.exports=o(44)},497:function(e){e.exports=require("react")}},r={};function o(t){var n=r[t];if(void 0!==n)return n.exports;var u=r[t]={exports:{}};return e[t](u,u.exports,o),u.exports}o.d=function(e,r){for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};return function(){o.r(t),o.d(t,{ScrollToTop:function(){return f},useScrollToTop:function(){return n}});var e=o(497),r=require("react-router-dom"),n=function(){var o=(0,r.useLocation)(),t=o.pathname,n=o.state;(0,e.useEffect)((function(){!1!==(null==n?void 0:n.scrollToTop)&&window.scrollTo(0,0)}),[t,n])},u=o(598),f=function(r){var o=r.children;return n(),(0,u.jsx)(u.Fragment,{children:e.Children.toArray(o)})}}(),t}()}));
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports["react-router-scroll-to-top"]=o():e["react-router-scroll-to-top"]=o()}(globalThis,function(){return function(){"use strict";var e={d:function(o,t){for(var r in t)e.o(t,r)&&!e.o(o,r)&&Object.defineProperty(o,r,{enumerable:!0,get:t[r]})},o:function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{ScrollToTop:function(){return u},useScrollToTop:function(){return n}});var t=require("react"),r=require("react-router-dom"),n=function(){var e=(0,r.useLocation)(),o=e.pathname,n=e.state;(0,t.useEffect)(function(){!1!==(null==n?void 0:n.scrollToTop)&&window.scrollTo(0,0)},[o,n])},u=function(e){var o=e.children;return n(),(0,t.createElement)(t.Fragment,null,t.Children.toArray(o))};return o}()});
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-router-scroll-to-top",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "React component that scrolls to the top of a page when the current location gets changed",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/dimazuien/react-router-scroll-to-top.git"
|
|
8
8
|
},
|
|
9
|
-
"homepage": "https://
|
|
9
|
+
"homepage": "https://github.com/dimazuien/react-router-scroll-to-top#readme",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"react",
|
|
12
12
|
"react router",
|
|
@@ -15,10 +15,6 @@
|
|
|
15
15
|
"scroll to top"
|
|
16
16
|
],
|
|
17
17
|
"author": "Dima Zuien",
|
|
18
|
-
"funding": {
|
|
19
|
-
"type": "patreon",
|
|
20
|
-
"url": "https://www.patreon.com/dimazuien"
|
|
21
|
-
},
|
|
22
18
|
"license": "MIT",
|
|
23
19
|
"bugs": {
|
|
24
20
|
"url": "https://github.com/dimazuien/react-router-scroll-to-top/issues"
|
|
@@ -31,76 +27,77 @@
|
|
|
31
27
|
"index.d.ts"
|
|
32
28
|
],
|
|
33
29
|
"sideEffects": false,
|
|
30
|
+
"packageManager": "pnpm@12.20.0",
|
|
34
31
|
"scripts": {
|
|
35
|
-
"
|
|
32
|
+
"prepare": "husky",
|
|
36
33
|
"build": "webpack",
|
|
37
|
-
"dts": "
|
|
34
|
+
"dts": "npm-dts generate -e src/index --tsc=\"-p tsconfig.build.json\"",
|
|
38
35
|
"lint": "eslint .",
|
|
39
36
|
"test": "jest",
|
|
40
|
-
"
|
|
41
|
-
"release": "semantic-release",
|
|
42
|
-
"postpublish": "pinst --enable"
|
|
37
|
+
"release": "semantic-release"
|
|
43
38
|
},
|
|
44
39
|
"devDependencies": {
|
|
45
|
-
"@babel/core": "7.
|
|
46
|
-
"@babel/preset-env": "7.
|
|
47
|
-
"@babel/preset-react": "7.
|
|
48
|
-
"@babel/preset-typescript": "7.
|
|
49
|
-
"@commitlint/cli": "
|
|
50
|
-
"@commitlint/config-conventional": "
|
|
51
|
-
"@semantic-release/changelog": "6.0.
|
|
52
|
-
"@semantic-release/commit-analyzer": "
|
|
40
|
+
"@babel/core": "7.29.13",
|
|
41
|
+
"@babel/preset-env": "7.29.14",
|
|
42
|
+
"@babel/preset-react": "7.29.7",
|
|
43
|
+
"@babel/preset-typescript": "7.29.7",
|
|
44
|
+
"@commitlint/cli": "21.2.2",
|
|
45
|
+
"@commitlint/config-conventional": "21.2.2",
|
|
46
|
+
"@semantic-release/changelog": "6.0.3",
|
|
47
|
+
"@semantic-release/commit-analyzer": "13.0.1",
|
|
53
48
|
"@semantic-release/git": "10.0.1",
|
|
54
|
-
"@semantic-release/github": "
|
|
55
|
-
"@semantic-release/npm": "
|
|
56
|
-
"@semantic-release/release-notes-generator": "
|
|
57
|
-
"@testing-library/dom": "
|
|
58
|
-
"@testing-library/jest-dom": "
|
|
59
|
-
"@testing-library/react": "
|
|
60
|
-
"@testing-library/user-event": "14.
|
|
61
|
-
"@types/jest": "
|
|
62
|
-
"@types/
|
|
63
|
-
"@types/react
|
|
49
|
+
"@semantic-release/github": "12.0.9",
|
|
50
|
+
"@semantic-release/npm": "13.1.5",
|
|
51
|
+
"@semantic-release/release-notes-generator": "14.1.1",
|
|
52
|
+
"@testing-library/dom": "10.4.2",
|
|
53
|
+
"@testing-library/jest-dom": "6.9.1",
|
|
54
|
+
"@testing-library/react": "16.3.3",
|
|
55
|
+
"@testing-library/user-event": "14.6.7",
|
|
56
|
+
"@types/jest": "29.5.14",
|
|
57
|
+
"@types/node": "26.6.6",
|
|
58
|
+
"@types/react": "19.3.0",
|
|
59
|
+
"@types/react-dom": "19.3.0",
|
|
64
60
|
"@types/react-router-dom": "5.3.3",
|
|
65
|
-
"@
|
|
66
|
-
"@typescript-eslint/
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
61
|
+
"@typescript-eslint/eslint-plugin": "7.18.0",
|
|
62
|
+
"@typescript-eslint/parser": "7.18.0",
|
|
63
|
+
"babel-loader": "10.1.1",
|
|
64
|
+
"commitizen": "4.3.2",
|
|
65
|
+
"conventional-changelog-conventionalcommits": "9.3.1",
|
|
70
66
|
"cz-conventional-changelog": "3.3.0",
|
|
71
|
-
"eslint": "8.
|
|
67
|
+
"eslint": "8.57.1",
|
|
72
68
|
"eslint-config-airbnb": "19.0.4",
|
|
73
|
-
"eslint-config-prettier": "
|
|
74
|
-
"eslint-plugin-import": "2.
|
|
75
|
-
"eslint-plugin-jest
|
|
76
|
-
"eslint-plugin-
|
|
77
|
-
"eslint-plugin-
|
|
78
|
-
"eslint-plugin-
|
|
79
|
-
"eslint-plugin-react
|
|
80
|
-
"eslint-plugin-
|
|
81
|
-
"eslint-plugin-
|
|
82
|
-
"
|
|
83
|
-
"github-markdown-css": "5.
|
|
84
|
-
"husky": "
|
|
85
|
-
"jest": "
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"react
|
|
93
|
-
"react-
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"ts-
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"webpack
|
|
69
|
+
"eslint-config-prettier": "10.1.8",
|
|
70
|
+
"eslint-plugin-import": "2.32.0",
|
|
71
|
+
"eslint-plugin-jest": "27.9.0",
|
|
72
|
+
"eslint-plugin-jest-dom": "5.10.1",
|
|
73
|
+
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
74
|
+
"eslint-plugin-prettier": "5.5.6",
|
|
75
|
+
"eslint-plugin-react": "7.37.5",
|
|
76
|
+
"eslint-plugin-react-hooks": "4.6.2",
|
|
77
|
+
"eslint-plugin-simple-import-sort": "14.0.0",
|
|
78
|
+
"eslint-plugin-testing-library": "7.16.2",
|
|
79
|
+
"github-markdown-css": "5.9.0",
|
|
80
|
+
"husky": "9.1.7",
|
|
81
|
+
"jest": "29.7.0",
|
|
82
|
+
"jest-environment-jsdom": "30.5.1",
|
|
83
|
+
"jest-junit": "17.0.0",
|
|
84
|
+
"lint-staged": "17.5.1",
|
|
85
|
+
"lorem-ipsum": "3.0.0",
|
|
86
|
+
"npm-dts": "1.3.13",
|
|
87
|
+
"prettier": "3.8.5",
|
|
88
|
+
"react": "19.3.1",
|
|
89
|
+
"react-dom": "19.3.1",
|
|
90
|
+
"react-router-dom": "7.18.6",
|
|
91
|
+
"semantic-release": "25.0.9",
|
|
92
|
+
"ts-jest": "29.4.12",
|
|
93
|
+
"ts-node": "10.9.2",
|
|
94
|
+
"typescript": "5.9.3",
|
|
95
|
+
"webpack": "5.110.3",
|
|
96
|
+
"webpack-cli": "7.2.3"
|
|
100
97
|
},
|
|
101
98
|
"peerDependencies": {
|
|
102
|
-
"react": "^16.8 || ^17 || ^18",
|
|
103
|
-
"react-dom": "^16.8 || ^17 || ^18",
|
|
104
|
-
"react-router-dom": "^5.1 || ^6"
|
|
99
|
+
"react": "^16.8 || ^17 || ^18 || ^19",
|
|
100
|
+
"react-dom": "^16.8 || ^17 || ^18 || ^19",
|
|
101
|
+
"react-router-dom": "^5.1 || ^6 || ^7"
|
|
105
102
|
}
|
|
106
103
|
}
|
package/lib/index.js.LICENSE.txt
DELETED