Skip to content

Commit

Permalink
fix(useScrollLock): check first effect (#8124)
Browse files Browse the repository at this point in the history
Проверяем что это не первый эффект при управлении скролллоком
  • Loading branch information
SevereCloud authored Dec 27, 2024
1 parent ba6b9c4 commit d9cbf49
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/vkui/src/components/AppRoot/ScrollContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,18 @@ export const useScroll = (): ScrollContextInterface => React.useContext(ScrollCo
* Если счетчик больше нуля, требуется заблокировать прокрутку
*/
function useScrollLockController(enableScrollLock: () => void, disableScrollLock: () => void) {
const isFirstEffect = React.useRef(true);
const [count, { increment: incrementScrollLockCounter, decrement: decrementScrollLockCounter }] =
useCounter(0);

const needLockScroll = count > 0;

React.useEffect(() => {
if (isFirstEffect.current) {
isFirstEffect.current = false;
return;
}

if (needLockScroll) {
enableScrollLock();
} else {
Expand Down

0 comments on commit d9cbf49

Please sign in to comment.