import React, { useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import Home from './pages/Home';
const App = () => {
const dispatch = useDispatch();
const { data } = useSelector((store) => store);
const [allowScroll, setAllowScroll] = useState(true);
const scrolling = () => {
const height = Math.max(
document.body.clientHeight,
document.documentElement.clientHeight
);
if (
window.pageYOffset > height * 0.75 ||
window.pageYOffset > height - 2000
) {
if (allowScroll) {
setAllowScroll(() => false);
setTimeout(() => {
setAllowScroll(() => true);
}, 2000);
dispatch({
type: 'DISPATCH',
});
}
}
};
return (
<div onWheel={scrolling}>
<Home />
</div>
);
};
export default App;