Skip to content

Commit 1c4c0de

Browse files
committed
update README
1 parent fa2d092 commit 1c4c0de

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ Check out [chris.bolin.co/offline](https://chris.bolin.co/offline) for a simple
6767
6868
[3] `<Detector/>` only
6969
70+
### Hooks
71+
72+
```jsx
73+
import { useConnection } from "react-detect-offline";
74+
75+
const App = () => {
76+
const { online } = useConnection();
77+
return (
78+
<div>
79+
{online && <p>Only shown when you're online</p>}
80+
{!online && <p>Only shown when you're offline</p>}
81+
</div>
82+
);
83+
};
84+
```
85+
7086
### Browser Support
7187
7288
The [web spec](https://developer.mozilla.org/en-US/docs/Online_and_offline_events) we rely on is supported by IE 9+, Chrome 14+, Firefox 41+, and Safari 5+ - that's [94% of worldwide (98% of US)](http://caniuse.com/#feat=online-status) browser traffic. A polling fallback is used for browsers that don't implement the spec in a useful way (see note [1] in the above Props section).

0 commit comments

Comments
 (0)