Skip to content

Commit

Permalink
Rename to useScrollListener
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Nov 1, 2024
1 parent 8426eb0 commit 9e5f17a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/desktop-client/src/components/ScrollProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ export function ScrollProvider<T extends Element>({
);
}

export function useScrollEffect(listener: ScrollListener) {
export function useScrollListener(listener: ScrollListener) {
const context = useContext(ScrollContext);
if (!context) {
throw new Error('useScrollEffect must be used within a ScrollProvider');
throw new Error('useScrollListener must be used within a ScrollProvider');
}

const { registerListener, unregisterListener } = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { SvgCalendar } from '../../icons/v2';
import { useResponsive } from '../../ResponsiveProvider';
import { theme, styles } from '../../style';
import { View } from '../common/View';
import { useScrollEffect } from '../ScrollProvider';
import { useScrollListener } from '../ScrollProvider';

const COLUMN_COUNT = 3;
const PILL_HEIGHT = 15;
Expand Down Expand Up @@ -123,7 +123,7 @@ export function MobileNavTabs() {
});
};

useScrollEffect(({ isScrolling }) => {
useScrollListener(({ isScrolling }) => {
if (isScrolling('down')) {
hide();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useRef } from 'react';
import { useListBox } from 'react-aria';
import { useListState } from 'react-stately';

import { useScrollEffect } from '../../ScrollProvider';
import { useScrollListener } from '../../ScrollProvider';

import { ListBoxSection } from './ListBoxSection';

Expand All @@ -12,7 +12,7 @@ export function ListBox(props) {
const { listBoxProps, labelProps } = useListBox(props, state, listBoxRef);
const { loadMore } = props;

useScrollEffect(({ hasScrolledToEnd }) => {
useScrollListener(({ hasScrolledToEnd }) => {
const scrolledToBottom = hasScrolledToEnd('down', 5);
if (scrolledToBottom) {
loadMore?.();
Expand Down

0 comments on commit 9e5f17a

Please sign in to comment.