Autoscrolling on mobile devices

This commit is contained in:
alxshelepenok 2019-02-09 15:54:31 +03:00
parent d31e82a2f9
commit 1ac51111f7

View File

@ -1,15 +1,23 @@
import React from 'react';
import React, { useRef, useEffect } from 'react';
import styles from './Page.module.scss';
const Page = ({ title, children }) => (
<div className={styles['page']}>
<div className={styles['page__inner']}>
{ title && <h1 className={styles['page__title']}>{title}</h1>}
<div className={styles['page__body']}>
{children}
const Page = ({ title, children }) => {
const pageRef = useRef();
useEffect(() => {
pageRef.current.scrollIntoView();
});
return (
<div ref={pageRef} className={styles['page']}>
<div className={styles['page__inner']}>
{ title && <h1 className={styles['page__title']}>{title}</h1>}
<div className={styles['page__body']}>
{children}
</div>
</div>
</div>
</div>
);
);
};
export default Page;