Skip to content

Commit

Permalink
Fix issue when using redux and checkIntervalOfflineOnly (#133)
Browse files Browse the repository at this point in the history
### What this PR fixes
If using redux integration and option `checkIntervalOfflineOnly`. 
It will never make a request to check internet connection. 
HOC `withNetworkConnectivity` has internal state, in which connection status is stored.
This however never gets updated. It's only set once during initialisation.
  • Loading branch information
usrbowe authored and rgommezz committed Dec 10, 2018
1 parent 2708ebd commit fc73028
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/withNetworkConnectivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ const withNetworkConnectivity = ({
}

setupConnectivityCheckInterval(() => {
if (this.state.isConnected && checkIntervalOfflineOnly) {
const { store } = this.context;
let isConnected = this.state.isConnected;
// When using redux integration, use store state for connection status
if (withRedux && store) {
isConnected = store.getState().network.isConnected;
}
if (isConnected && checkIntervalOfflineOnly) {
return;
}
this.checkInternet();
Expand Down

0 comments on commit fc73028

Please sign in to comment.