Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add useScrollToTop.js to hooks #644

Merged
merged 3 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions FrontEnd/src/components/Contact/Contact.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, { useEffect } from 'react';
import React from 'react';
import renderContent from '../CookiesPolicyPage/RenderContent.jsx';
import LinkContainer from '../CookiesPolicyPage/LinkContainer.jsx';
import styles from './Contact.module.css';
import contactText from './text';
import TEXT_CONTENT from './text';
import useScrollToTop from '../../hooks/useScrollToTop';

const Contact = () => {
useEffect(() => {
window.scrollTo(0, 0);
}, []);
useScrollToTop();

return (
<div className={styles['contact_container']}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, { useEffect } from 'react';
import React from 'react';
import styles from './cookiesPolicyComponent.module.css';
import CookiesPolicyText from './text.js';
import TEXT_CONTENT from './text.js';
import LinkContainer from './LinkContainer.jsx';
import renderContent from './RenderContent.jsx';
import useScrollToTop from '../../hooks/useScrollToTop';

const CookiesPolicy = () => {
useEffect(() => {
window.scrollTo(0, 0);
}, []);
useScrollToTop();

return (
<div className={styles['cookies_policy']}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HashLink } from 'react-router-hash-link';
import { Link } from 'react-router-dom';
import css from './FooterNavigation.module.css';
import useScrollToTop from '../../../../hooks/useScrollToTop';

const PAGE_NAVIGATION_LINKS = [
{
Expand Down Expand Up @@ -51,6 +52,8 @@ const CONTACTS = [
];

function FooterNavigation() {
useScrollToTop();

return (
<div className={css['navigation-content']}>
<div className={css['navigation-content-section']}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { useEffect } from 'react';
import React from 'react';
import styles from './PrivacyPolicy.module.css';
import privacyPolicyText from './text';
import TEXT_CONTENT from './text';
import LinkContainer from '../CookiesPolicyPage/LinkContainer.jsx';
import renderContent from '../CookiesPolicyPage/RenderContent.jsx';
import useScrollToTop from '../../hooks/useScrollToTop';


const PrivacyPolicy = () => {
useEffect(() => {
window.scrollTo(0, 0);
}, []);
useScrollToTop();

return (
<div className={styles['privacy_policy']}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { useEffect } from 'react';
import React from 'react';
import styles from './TermsAndConditionsComponent.module.css';
import TermsAndConditionsText from './text';
import TEXT_CONTENT from './text';
import LinkContainer from '../../CookiesPolicyPage/LinkContainer.jsx';
import renderContent from '../../CookiesPolicyPage/RenderContent.jsx';
import useScrollToTop from '../../../hooks/useScrollToTop';


const TermsAndConditions = () => {
useEffect(() => {
window.scrollTo(0, 0);
}, []);
useScrollToTop();

return (
<div className={styles['TermsAndConditions']}>
Expand Down
12 changes: 12 additions & 0 deletions FrontEnd/src/hooks/useScrollToTop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

const useScrollToTop = () => {
const location = useLocation();

useEffect(() => {
window.scrollTo(0, 0);
}, [location]);
};

export default useScrollToTop;
Loading