Skip to content

Commit

Permalink
Fixes rehooks#12
Browse files Browse the repository at this point in the history
  • Loading branch information
ritwickdey authored Jul 26, 2019
1 parent 389c994 commit 60d2756
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ function getOnlineStatus() {
function useOnlineStatus() {
const [onlineStatus, setOnlineStatus] = useState(getOnlineStatus());

const goOnline = () => setOnlineStatus(true);

const goOffline = () => setOnlineStatus(false);


useEffect(() => {
const goOnline = () => setOnlineStatus(true);
const goOffline = () => setOnlineStatus(false);

window.addEventListener("online", goOnline);
window.addEventListener("offline", goOffline);

Expand Down

0 comments on commit 60d2756

Please sign in to comment.