File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ export const MyItemList = (items) => (
9292 < / table>
9393)
9494```
95+
9596The example above, builds a valid HTML table like the one shown below:
9697```
9798 <table class="my-list">
Original file line number Diff line number Diff line change 1313 "scripts" : {
1414 "build" : " rollup -c" ,
1515 "start" : " rollup -c -w" ,
16- "prettier" : " prettier --write ./src"
16+ "prettier" : " prettier --write ./src" ,
17+ "publish" : " np"
1718 },
1819 "dependencies" : {},
1920 "peerDependencies" : {
Original file line number Diff line number Diff line change @@ -43,11 +43,12 @@ const RenderIfVisible = ({
4343 // Set visibility with intersection observer
4444 useEffect ( ( ) => {
4545 if ( intersectionRef . current ) {
46+ const localRef = intersectionRef . current
4647 const observer = new IntersectionObserver (
4748 ( entries ) => {
4849 // Before switching off `isVisible`, set the height of the placeholder
4950 if ( ! entries [ 0 ] . isIntersecting ) {
50- placeholderHeight . current = intersectionRef . current ! . offsetHeight
51+ placeholderHeight . current = localRef ! . offsetHeight
5152 }
5253 if ( typeof window !== undefined && window . requestIdleCallback ) {
5354 window . requestIdleCallback (
@@ -62,10 +63,11 @@ const RenderIfVisible = ({
6263 } ,
6364 { root, rootMargin : `${ visibleOffset } px 0px ${ visibleOffset } px 0px` }
6465 )
65- observer . observe ( intersectionRef . current )
66+
67+ observer . observe ( localRef )
6668 return ( ) => {
67- if ( intersectionRef . current ) {
68- observer . unobserve ( intersectionRef . current )
69+ if ( localRef ) {
70+ observer . unobserve ( localRef )
6971 }
7072 }
7173 }
You can’t perform that action at this time.
0 commit comments