Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'TypeError undefined is not a function' when componentWillUnmout() in App.js #11

Open
mattvaldez opened this issue Apr 29, 2020 · 0 comments

Comments

@mattvaldez
Copy link

mattvaldez commented Apr 29, 2020

Hello, thank you for the great library!
We recently started logging an error on Android devices with the message TypeError undefined is not a function. The error has been logged hundreds of times in a few hours (we do not have very many users either). We are not experiencing this at all on iOS, it seems to be only affecting Android.
The top of the stack trace looks like this:

TypeError undefined is not a function node_modules/react-native-redux-connectivity/src/NetworkMonitor.js:50:12 value

The exception is being caught in our App.js inside componentWillUnmount(), which only has one function inside it:
this.networkMonitor.stop()

Here is what the entire App.js looks like:

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Animated, Easing} from 'react-native';
import { Provider } from 'react-redux';
import { store, persistor } from './store';
import { createAppContainer, createStackNavigator } from 'react-navigation';
import LoginScreen from './screens/LoginScreen';
import SurveyListScreen from './screens/SurveyListScreen';
import RecordsListScreen from './screens/RecordsListScreen';
import SurveyFormScreen from './screens/SurveyFormScreen';
import AppSettingsScreen from './screens/AppSettingsScreen';
import {NetworkMonitor} from 'react-native-redux-connectivity'
import { PersistGate } from 'redux-persist/integration/react';

const RootStack = createStackNavigator({
  Login: LoginScreen,
  SurveyList: SurveyListScreen,
  RecordsList: RecordsListScreen,
  SurveyForm: SurveyFormScreen,
  AppSettings: AppSettingsScreen
},
{
  headerLayoutPreset: 'center',
  defaultNavigationOptions: {
    gesturesEnabled: false
  },
  transitionConfig : () => ({
  	transitionSpec: {
  		duration: 0,
  		timing: Animated.timing,
  		easing: Easing.step0,
  	},
  }),
  headerMode: 'float'
});

const Navigator = createAppContainer(RootStack);

export default class App extends Component {

  constructor(props) {
    super(props);
    this.networkMonitor = new NetworkMonitor(store);
    this.networkMonitor.start();
  }

  componentWillUnmount() {
    this.networkMonitor.stop();
  }

  render() {
    // persistor.purge()
    return (
      <Provider store={store}>
        <PersistGate persistor={persistor}>
          <Navigator />
        </PersistGate>
      </Provider>
    );
  }
}

I am having a very hard time troubleshooting this, or even finding any resources to go on. Here is some more info about our environment:
react -> 16.9.0
react-native -> 0.61.1
react-native-redux-connectivity -> 0.2.1
@react-native-community/netinfo -> 5.7.1

Hopefully you can provide some more insight as to how I can solve this, let me know if you need more information. Thank you!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant