Skip to content

Commit 09ae202

Browse files
committed
fix(useInfiniteScroll): fixes console.error message
1 parent 54a7201 commit 09ae202

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,3 +981,15 @@ Errored release
981981
### Adds
982982

983983
- improve `useInfiniteScroll` code
984+
985+
## [3.12.1] - 2023-01-11
986+
987+
### Fixes
988+
989+
- Fixes `useInfiniteScroll` not working on Windows machines
990+
991+
## [3.12.2] - 2023-01-11
992+
993+
### Fixes
994+
995+
- Fixes `useInfiniteScroll` console.error message

src/useInfiniteScroll.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const useInfiniteScroll = <TElement extends HTMLElement>(ref: RefObject<TElement
2323
if (el) {
2424
const isBottom = Math.abs(el.scrollHeight - el.clientHeight - el.scrollTop) < 1
2525

26-
event.preventDefault()
26+
// event.preventDefault()
2727
event.stopPropagation()
2828

2929
if (isBottom && isFunction(onScrollEnd?.current)) {

test/warnOnce.spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { createSandbox } from 'sinon'
2+
import assertFunction from './utils/assertFunction'
3+
import warnOnce from '../dist/shared/warnOnce'
4+
5+
describe('warnOnce', () => {
6+
assertFunction(warnOnce)
7+
8+
const sandbox = createSandbox()
9+
10+
beforeEach(() => {
11+
sandbox.spy(console, 'warn')
12+
})
13+
14+
afterEach(() => {
15+
sandbox.restore()
16+
})
17+
18+
it('should not warn the same message twice', () => {
19+
const message = 'foo'
20+
const repeats = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
21+
22+
repeats.forEach(() => warnOnce(message))
23+
24+
expect(console.warn.calledOnce).to.be.true
25+
})
26+
})

0 commit comments

Comments
 (0)