react-visibility-hooks 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,12 +21,6 @@ A collection of lightweight React hooks that help you build performance-consciou
|
|
|
21
21
|
npm install react-visibility-hooks
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
For `useSmartPolling`, you'll also need to install `@tanstack/react-query`:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install @tanstack/react-query
|
|
28
|
-
```
|
|
29
|
-
|
|
30
24
|
## Hooks
|
|
31
25
|
|
|
32
26
|
### `useDocVisible`
|
|
@@ -104,7 +98,7 @@ function VideoPlayer() {
|
|
|
104
98
|
|
|
105
99
|
### `useSmartPolling`
|
|
106
100
|
|
|
107
|
-
Smart polling that only
|
|
101
|
+
Smart polling that only fetches data when the page is visible. Zero additional dependencies required.
|
|
108
102
|
|
|
109
103
|
**Use cases:**
|
|
110
104
|
- Real-time dashboards
|
|
@@ -126,7 +120,11 @@ function Dashboard() {
|
|
|
126
120
|
}
|
|
127
121
|
```
|
|
128
122
|
|
|
129
|
-
**
|
|
123
|
+
**Options:**
|
|
124
|
+
- `interval` (optional): Polling interval in milliseconds (default: 5000)
|
|
125
|
+
- `enabled` (optional): Enable/disable polling (default: true)
|
|
126
|
+
|
|
127
|
+
Polling is automatically paused when the tab is hidden and resumes when visible.
|
|
130
128
|
|
|
131
129
|
## SSR Support
|
|
132
130
|
|