File tree Expand file tree Collapse file tree 3 files changed +5
-7
lines changed Expand file tree Collapse file tree 3 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import * as React from 'react';
22import { InView } from './InView' ;
33export { InView } from './InView' ;
44export { useInView } from './useInView' ;
5- export { observe , _observerMap } from './observe' ;
5+ export { observe } from './observe' ;
66
77export default InView ;
88
Original file line number Diff line number Diff line change 11import { ObserverInstanceCallback } from './index' ;
22
3- export const _observerMap = new Map <
3+ const observerMap = new Map <
44 string ,
55 {
66 id : string ;
@@ -44,7 +44,7 @@ export function optionsToId(options: IntersectionObserverInit) {
4444function createObserver ( options : IntersectionObserverInit ) {
4545 // Create a unique ID for this observer instance, based on the root, root margin and threshold.
4646 let id = optionsToId ( options ) ;
47- let instance = _observerMap . get ( id ) ;
47+ let instance = observerMap . get ( id ) ;
4848
4949 if ( ! instance ) {
5050 // Create a map of elements this observer is going to observe. Each element has a list of callbacks that should be triggered, once it comes into view.
@@ -85,7 +85,7 @@ function createObserver(options: IntersectionObserverInit) {
8585 elements,
8686 } ;
8787
88- _observerMap . set ( id , instance ) ;
88+ observerMap . set ( id , instance ) ;
8989 }
9090
9191 return instance ;
@@ -128,7 +128,7 @@ export function observe(
128128 if ( elements . size === 0 ) {
129129 // No more elements are being observer by this instance, so destroy it
130130 observer . disconnect ( ) ;
131- _observerMap . delete ( id ) ;
131+ observerMap . delete ( id ) ;
132132 }
133133 } ;
134134}
Original file line number Diff line number Diff line change 11import { act } from 'react-dom/test-utils' ;
2- import { _observerMap } from './index' ;
32
43type Item = {
54 callback : IntersectionObserverCallback ;
@@ -49,7 +48,6 @@ afterEach(() => {
4948 // @ts -ignore
5049 global . IntersectionObserver . mockClear ( ) ;
5150 observers . clear ( ) ;
52- _observerMap . clear ( ) ;
5351} ) ;
5452
5553function triggerIntersection (
You can’t perform that action at this time.
0 commit comments