Closed dustinromey closed 5 years ago
I wrote a medium article to showcase some real life examples. Please check https://blog.callstack.io/your-react-native-offline-tool-belt-795abd5f0183
Yep, saw the article linked from the readme. And to be clear, thanks! Its a great explanation of your library's value and intro to its usage.
Just think a full cycle of the library's usage would be helpful in mentally following it, and assumed this was the correct way to say so.
Agree that an example app would be helpful. In the meantime, maybe you could tell me what you are struggling with in particular and I can try to help you out.
@rauliyohmc I have integrated the lib in Redux Middleware
way, I want to know where and how to use.
I'm using an ignite-based project
Also, state.network.isConnected
is always true even if there is no internet connection
@engmsaleh, I believe https://github.com/rauliyohmc/react-native-offline#how-to-orchestrate-redux-to-dispatch-connection_change-as-the-first-action-when-the-app-starts-up should resolve that problem.
Platform: macOS High Sierra v10.13.1 Android Emulator: Nexus 6 API 23
Refer to https://github.com/rauliyohmc/react-native-offline#how-to-orchestrate-redux-to-dispatch-connection_change-as-the-first-action-when-the-app-starts-up and setup
App = withNetworkConnectivity({
withRedux: true // It won't inject isConnected as a prop in this case
})(App);
After I switched the data status from Home to Denied in Android Emulator, Redux-logger shows the actions dispatched is
{type: "@@network-connectivity/CONNECTION_CHANGE", payload: false}
and the next state of network.isConnected remains true
Should we handle the action in the network reducer manually?
function reducer(state: NetworkState = initialState, action: Action): NetworkState {
switch (action.type) {
// handle the action manually
case '@@network-connectivity/CONNECTION_CHANGE':
return {
...state,
isConnected: action.payload,
};
default:
return state;
}
}
@vshy108, are you setting up network
reducer as per the docs? You may be missing step 1: https://github.com/rauliyohmc/react-native-offline#1--give-the-network-reducer-to-redux
Same problem with me, state.network.isConnected
is always true even if there is no internet connection :
const reducers = combineReducers({
nav: navReducer,
i18n: i18nReducer,
app: appReducer,
storage: storageReducer,
network
});
And my container :
const SyncButtonContainer = withNetworkConnectivity({
withRedux: true,
checkConnectionInterval: 1000
})(connect(
mapStateToProps,
mapDispatchToProps
)(SyncButton));
Anyone have idea ?
I tried following https://github.com/rauliyohmc/react-native-offline#how-to-orchestrate-redux-to-dispatch-connection_change-as-the-first-action-when-the-app-starts-up but ended up with the following error:
TypeError: (0, _reduxPersist.autoRehydrate) is not a function. (In '(0, _reduxPersist.autoRehydrate)()', '(0, _reduxPersist.autoRehydrate)' is undefined)
After a bit of research, I notice a few issues in their end stating to use v4 of redux-persist. I downgraded to v4 and now it works.
The issue now is that after going into airplane mode, the isConnected
changes to false
like it's suppose to but now it doesn't change back to true
after the connection is restored.
Any ideas?
@johhansantana I'm having the very same problem, once I get isConnected to false, even after connection is restored it never returns true. I'll try debugging some more to find out. I'm not even using redux, just ConnectivityRenderer out of the box.
Thanks
Just found out, by default the lib pings google using http, and ios blocks it. Changing to https should work. BTW @rgommezz I really think that the default url should use https, what do you think?
Thanks
@boostio funded this issue with $20. Visit this issue on Issuehunt
@issuehuntfest has funded $300.00 to this issue. See it on IssueHunt
@norris1z has submitted a pull request. See it on IssueHunt
@rgommezz has cancelled their pull request. See it on IssueHunt
@rgommezz has rewarded $224.00 to @rgommezz. See it on IssueHunt
This is an issue I'm struggling with on my current project. What would be very very useful is an example project to show typical usage.
So sort of something like this repository: https://github.com/spencercarli/offline-redux-actions, for this article: https://medium.com/differential/handling-offline-actions-in-react-native-74949cbfabf2