Skip to content

Commit 9348aab

Browse files
committed
chore: upgrade dependencies and readme
1 parent 4129884 commit 9348aab

File tree

3 files changed

+1038
-933
lines changed

3 files changed

+1038
-933
lines changed

README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,18 @@ argument for the hooks.
153153
| **threshold** | number \| number[] | 0 | false | Number between 0 and 1 indicating the percentage that should be visible before triggering. Can also be an array of numbers, to create multiple trigger points. |
154154
| **triggerOnce** | boolean | false | false | Only trigger this method once |
155155

156-
> ⚠️ When passing an array to `threshold`, store the array in a constant to avoid
157-
> the component re-rendering too often. For example:
156+
> ⚠️ When passing an array to `threshold`, store the array in a constant to
157+
> avoid the component re-rendering too often. For example:
158158
159159
```js
160-
const THRESHOLD = [0.25, 0.5, 0.75]; // Store multiple thresholds in a constant
160+
const THRESHOLD = [0.25, 0.5, 0.75] // Store multiple thresholds in a constant
161161
const MyComponent = () => {
162-
const [ref, inView, entry] = useInView({threshold: THRESHOLD});
163-
return <div ref={ref}>Triggered at intersection ratio {entry.intersectionRatio}</div>;
162+
const [ref, inView, entry] = useInView({ threshold: THRESHOLD })
163+
return (
164+
<div ref={ref}>
165+
Triggered at intersection ratio {entry.intersectionRatio}
166+
</div>
167+
)
164168
}
165169
```
166170

@@ -183,20 +187,23 @@ few ideas for how you can use it.
183187
- [Trigger animations](docs/Recipes.md#trigger-animations)
184188
- [Track impressions](docs/Recipes.md#track-impressions) _(Google Analytics, Tag
185189
Manager, etc)_
186-
190+
187191
## FAQ
188192

189193
### How can i assign multiple ref's to a component?
190194

191195
You can wrap multiple `ref` assignments in a single `useCallback`:
192196

193197
```js
194-
const setRefs = useCallback(node => {
195-
// Ref's from useRef needs to have the node assigned to `current`
196-
ref.current = node
197-
// Callback refs, like the one from `useInView`, is a function that takes the node as an argument
198-
inViewRef(node)
199-
}, [inViewRef])
198+
const setRefs = useCallback(
199+
node => {
200+
// Ref's from useRef needs to have the node assigned to `current`
201+
ref.current = node
202+
// Callback refs, like the one from `useInView`, is a function that takes the node as an argument
203+
inViewRef(node)
204+
},
205+
[inViewRef],
206+
)
200207
```
201208

202209
## Testing

src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export type PlainChildrenProps = IntersectionOptions & {
6767
} & Omit<React.HTMLProps<HTMLElement>, 'onChange'>
6868

6969
export type InViewHookResponse = [
70-
((node?: Element | null) => void),
70+
(node?: Element | null) => void,
7171
boolean,
72-
IntersectionObserverEntry | undefined
72+
IntersectionObserverEntry | undefined,
7373
]

0 commit comments

Comments
 (0)