react-mkx-toolkit
Advanced tools
Comparing version 1.8.1 to 1.8.2
{ | ||
"name": "react-mkx-toolkit", | ||
"version": "1.8.1", | ||
"version": "1.8.2", | ||
"description": "React Custom Hooks provide an efficient means to encapsulate and share logic among components within React applications. This package includes useful React custom hooks.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -20,2 +20,3 @@ ## React Useful Custom Hooks | ||
- [useNotification](#useNotification) | ||
- [useOnlineStatus](#useOnlineStatus) | ||
- [License](#license) | ||
@@ -200,2 +201,32 @@ - [Author](#author) | ||
## useOnlineStatus | ||
The `useOnlineStatus` hook helps you track the browser’s online/offline status. It utilizes the navigator.onLine property and listens to the online and offline events to update the status in real time. | ||
## Usage | ||
```jsx | ||
import React from "react"; | ||
import { useOnlineStatus } from "react-mkx-toolkit"; | ||
const MyComponent = () => { | ||
const isOnline = useOnlineStatus(); | ||
return ( | ||
<div> | ||
<h1>Network Status</h1> | ||
<p>{isOnline ? "🟢 Online" : "🔴 Offline"}</p> | ||
</div> | ||
); | ||
}; | ||
export default MyComponent; | ||
``` | ||
### Features | ||
- Automatically updates when the browser goes online or offline. | ||
- Compatible with modern browsers and React versions. | ||
- Useful for network-aware components or offline-first applications. | ||
## Browser Support | ||
@@ -202,0 +233,0 @@ |
37546
28
704
247