Skip to content

Commit 75f9f28

Browse files
committed
docs: update readme
1 parent 12a9065 commit 75f9f28

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,13 @@ const Component = () => {
7575

7676
```js
7777
const inViewRef = useOnInView(
78-
(enterEntry) => {
79-
// Do something with the element that came into view
80-
console.log('Element is in view', enterEntry?.target);
81-
82-
// Optionally return a cleanup function
83-
return (exitEntry) => {
84-
console.log('Element moved out of view or unmounted');
85-
};
78+
(inView, entry) => {
79+
if (inView) {
80+
// Do something with the element that came into view
81+
console.log("Element is in view", entry.target);
82+
} else {
83+
console.log("Element left view", entry.target);
84+
}
8685
},
8786
options // Optional IntersectionObserver options
8887
);

0 commit comments

Comments
 (0)