redux-offline: Cannot read property 'getConnectionInfo' of undefined
Issue
Cannot use redux-offline with react-native 0.60.5
Are you using offline() or createOffline() API?
offline()
If you’re using createOffline() API, be sure to use compose() in the right order.
Store config
Please paste your config below.
import { offline } from "@redux-offline/redux-offline";
import offlineConfig from "@redux-offline/redux-offline/lib/defaults";
import {
applyMiddleware,
combineReducers,
compose,
createStore,
Middleware
} from "redux";
import thunk, { ThunkAction } from "redux-thunk";
import { DeepReadonly } from "utility-types";
import {
ItemActions,
itemReducer,
Items,
ListActions,
listReducer,
Lists
} from "../../apps/Checklists/models";
import {
Choices,
ChoicesActions,
choicesReducer,
Questionnaires,
QuestionnairesActions,
questionnairesReducer,
Questions,
QuestionsActions,
questionsReducer,
Responses,
ResponsesActions,
responsesReducer
} from "../../apps/Debug/screens/Questionnaire/models";
import {
AppActions,
appReducer,
AppState,
AuthActions,
authReducer,
AuthState,
DeviceActions,
deviceReducer,
DeviceState,
Navigation,
NavigationActions,
navigationReducer,
Theme,
ThemeActions,
themeReducer
} from "../../models";
/* INTERFACES */
export type RootState = DeepReadonly<{
app: AppState;
auth: AuthState;
device: DeviceState;
items: Items;
lists: Lists;
navigation: Navigation;
questions: Questions;
choices: Choices;
responses: Responses;
questionnaires: Questionnaires;
theme: Theme;
}>;
/* REDUCERS */
const reducers = combineReducers<RootState>({
app: appReducer,
auth: authReducer,
choices: choicesReducer,
device: deviceReducer,
items: itemReducer,
lists: listReducer,
navigation: navigationReducer,
questionnaires: questionnairesReducer,
questions: questionsReducer,
responses: responsesReducer,
theme: themeReducer
});
/* ACTIONS */
export type RootAction =
| AppActions
| DeviceActions
| AuthActions
| ListActions
| ItemActions
| NavigationActions
| QuestionnairesActions
| QuestionsActions
| ChoicesActions
| ResponsesActions
| ThemeActions;
export type RootThunkAction<R> = ThunkAction<R, RootState, {}, RootAction>;
/* CONSTANTS */
const middlewares: Middleware[] = [thunk];
const composers =
(window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const enhancers = composers(
applyMiddleware(...middlewares)
offline(offlineConfig)
);
/* STORE */
export const store = createStore(reducers, enhancers);
Offline config
No
Are you reporting a bug?
Yes
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 23 (10 by maintainers)
@yanavoznuk @ethanneff @izkmdz Are you seeing this issue with iOS or android?
I have my development environment set up (iOS) and I’m seeing no issues with the current package. My setup:
.
When I log the netinfo package in my environment I see all methods available for use:
Even though some methods are deprecated, they haven’t been removed from use just yet.
@yanavoznuk your error is coming from
_reactNative.NetInfo.getConnection, if I force mine to error it comes straight from_netInfo.methodNamewhich leads me to believe that your node_modules file isn’t quite clean/up to date since it looks like it’s pulling from RN directly, not the community package. Can you clean and re-install your node modules, make sure that you have run areact-native link @react-native-community/netinfoif necessary and run apod installin the relevant directory.Ah, I see the issue. the community package is a stripped down version of the original net info package and there are a couple of methods that do not exist anymore. I think it may also be getting confused between the pre-existing legacy (the legacy, legacy) implementation.
I’m going to take a little dive into this, bare with me though as even though I’m a maintainer I’ve not touched the native side of the code yet/used RN. I think this should be simple to fix though (hopefully) - but I’ve got to bootstrap that environment first.
In the mean time you might be able to roll your own network detect (copy the existing in src and make the necessary changes).
We are also running into this same issue with redux-offline
2.5.2-native.1while attempting to migrate our project to react-native0.60.5.This is the error:
It could be related to NetInfo being removed from version
0.60. Importing react-native-netinfo as a package and usingresolutionsas described here has unfortunately not solved the issue.