mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-11-11 05:56:40 +01:00
refactor(starter): upgrade to new version of gatsby
This commit is contained in:
31
src/components/Page/Page.tsx
Normal file
31
src/components/Page/Page.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import React, { useEffect, useRef } from "react";
|
||||
|
||||
import type { Nullable } from "@/types";
|
||||
|
||||
import styles from "./Page.module.scss";
|
||||
|
||||
interface Props {
|
||||
title?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
const Page: React.FC<Props> = ({ title, children }: Props) => {
|
||||
const pageRef = useRef<Nullable<HTMLDivElement>>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (pageRef.current) {
|
||||
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>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
Reference in New Issue
Block a user