mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 04:09:45 +00:00
Перебросил useEffect из Main в Root и оформил как контекст
This commit is contained in:
1 parent
8496cae1aa
commit
ce0752c7eb
5 files changed
+72
-55
No files matched your search
+11
-20
@@ -1,31 +1,22 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useContext } from 'react';
|
||||
|
||||
import { News, Projects, Labs, Partners, Gallery, ContactUs } from './components';
|
||||
import useElementOnScreen from '../../lib/useElementOnScreen';
|
||||
import { RootContext } from '../Root';
|
||||
|
||||
import './Main.styles.scss';
|
||||
|
||||
function Main() {
|
||||
const [containerRef, isVisible] = useElementOnScreen({
|
||||
root: null,
|
||||
rootMargin: '0px',
|
||||
threshold: 0,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const [ navbar ] = document.getElementsByClassName('navbar');
|
||||
if (isVisible) {
|
||||
navbar.classList.add('absolute');
|
||||
} else {
|
||||
navbar.classList.remove('absolute');
|
||||
}
|
||||
}, [isVisible]);
|
||||
const { containerRef } = useContext(RootContext);
|
||||
|
||||
return (
|
||||
<>
|
||||
<header className="header" id="mainpageheader" ref={containerRef}>
|
||||
<h1>Думай иначе, будь креативным!</h1>
|
||||
<h2>Студенческое конструкторское бюро<br />
|
||||
"Компьютерное инновационное творчество"</h2>
|
||||
<a className="btn" href="">Связаться с нами</a>
|
||||
<div className="container">
|
||||
<h1>Думай иначе, будь креативным!</h1>
|
||||
<h2>Студенческое конструкторское бюро<br />
|
||||
"Компьютерное инновационное творчество"</h2>
|
||||
<a className="btn" href="">Связаться с нами</a>
|
||||
</div>
|
||||
</header>
|
||||
<div className="content">
|
||||
<News />
|
||||
|
||||
Reference in new issue
Block a user