Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aitoolkit-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nomad-lab
aitoolkit-gui
Commits
f66b8570
Commit
f66b8570
authored
Mar 17, 2022
by
Luigi Sbailo
Browse files
Options
Downloads
Patches
Plain Diff
Add scroll to top
parent
6296ae36
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/routes.js
+30
-10
30 additions, 10 deletions
src/routes.js
with
30 additions
and
10 deletions
src/routes.js
+
30
−
10
View file @
f66b8570
import
React
from
'
react
'
;
import
React
,
{
useEffect
}
from
'
react
'
;
import
MainPage
from
'
./components/MainPage
'
;
import
ReproducePage
from
'
./components/ReproducePage
'
;
import
TutorialsPage
from
'
./components/TutorialsPage
'
;
import
{
Route
,
Switch
,
Redirect
}
from
'
react-router-dom
'
;
import
{
BrowserRouter
as
Router
,
Route
,
Switch
,
Redirect
,
withRouter
,
useLocation
}
from
'
react-router-dom
'
;
function
_ScrollToTop
(
props
)
{
const
{
pathname
}
=
useLocation
();
useEffect
(()
=>
{
window
.
scrollTo
(
0
,
0
);
},
[
pathname
]);
return
props
.
children
}
const
ScrollToTop
=
withRouter
(
_ScrollToTop
)
export
const
Routes
=
()
=>
{
return
(
<
div
>
<
Router
>
<
ScrollToTop
>
<
Switch
>
<
Route
exact
path
=
"
/Main
"
component
=
{
MainPage
}
/
>
<
Route
exact
path
=
"
/
"
>
...
...
@@ -16,7 +34,9 @@ export const Routes = () => {
<
Route
exact
path
=
"
/Reproduce
"
component
=
{
ReproducePage
}
/
>
<
Route
exact
path
=
"
/Tutorials
"
component
=
{
TutorialsPage
}
/
>
<
/Switch
>
<
/ScrollToTop
>
<
/Router
>
<
/div
>
);
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment