Undefined不是函数(评估'ReactComponentTreeHook.purgeUnmountedComponents()'

时间:2017-11-18 00:27:06

标签: react-native

我正面临这个错误并试图从互联网上研究但没有运气。 它只是突然发生没有理由所以我不知道如何重现错误。 我遵循了这个解决方案(https://github.com/facebook/react/issues/8454)。试图卸载,再次安装反应js但仍然相同。 有人可以帮忙看看这个吗? 非常感谢。 这是我的package.json

{
  "name": "AwesomeLeadership",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@monterosa/react-native-parallax-scroll": "^1.0.4",
    "create-react-class": "^15.6.2",
    "dateformat": "^2.0.0",
    "k-core": "0.0.1-alpha.2",
    "lodash-node": "^3.10.2",
    "native-base": "^2.3.1",
    "prop-types": "^15.6.0",
    "pusher-js": "^4.0.0",
    "react": "^16.1.1",
    "react-debbuger": "0.0.1",
    "react-native": "^0.47.1",
    "react-native-autogrow-textinput": "^4.0.0",
    "react-native-autolink": "^1.1.1",
    "react-native-confetti": "0.0.6",
    "react-native-console-panel": "^0.1.0",
    "react-native-deprecated-custom-components": "^0.1.1",
    "react-native-drawer": "^2.3.0",
    "react-native-drop-refresh": "^2.2.0",
    "react-native-dropdown-menu": "^1.1.0",
    "react-native-easy-grid": "^0.1.15",
    "react-native-easy-toast": "^1.0.6",
    "react-native-i18n": "^2.0.1",
    "react-native-image-picker": "^0.25.1",
    "react-native-keyboard-aware-scroll-view": "^0.3.0",
    "react-native-keyboard-aware-scrollview": "^1.1.7",
    "react-native-keyboard-manager": "^4.0.10-3",
    "react-native-keyboard-spacer": "^0.4.1",
    "react-native-lightbox": "^0.7.0",
    "react-native-loading-spinner-overlay": "^0.5.2",
    "react-native-media-kit": "git+https://github.com/ldn0x7dc/react-native-media-kit.git#pull/30/head",
    "react-native-modal": "^3.0.2",
    "react-native-modal-datetime-picker": "^4.7.0",
    "react-native-modal-dropdown": "^0.4.4",
    "react-native-modal-wrapper": "^2.3.0",
    "react-native-mov-to-mp4": "^0.2.1",
    "react-native-multiple-select": "^0.2.1",
    "react-native-native-video-player": "^1.3.4",
    "react-native-orientation": "git+https://git@github.com/yamill/react-native-orientation.git",
    "react-native-photo-view": "^1.3.0",
    "react-native-progress": "^3.3.0",
    "react-native-progress-bar-classic": "^1.2.1",
    "react-native-push-notification": "^2.2.1",
    "react-native-scrollable-tab-view": "^0.8.0",
    "react-native-simple-modal": "^6.0.0",
    "react-native-slider": "^0.10.0",
    "react-native-spinkit": "^1.1.1",
    "react-native-star-rating": "^1.0.7",
    "react-native-swiper": "^1.5.4",
    "react-native-textinput-effects": "^0.4.1",
    "react-native-thumbnail": "^1.0.8",
    "react-native-triangle": "0.0.9",
    "react-native-vector-icons": "^4.0.0",
    "react-native-video": "^2.0.0",
    "react-redux": "^4.4.5",
    "redux": "^3.6.0",
    "redux-logger": "^2.7.4",
    "redux-persist": "^4.0.1",
    "redux-thunk": "^2.1.0",
    "underscore": "^1.8.3"
  },
  "jest": {
    "preset": "jest-react-native"
  },
  "devDependencies": {
    "babel-eslint": "^7.1.1",
    "babel-jest": "17.0.0",
    "babel-preset-react-native": "1.9.0",
    "eslint": "^3.11.1",
    "eslint-config-airbnb": "^13.0.0",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^2.2.3",
    "eslint-plugin-react": "^6.7.1",
    "jest": "^17.0.0",
    "jest-react-native": "17.0.0",
    "react-test-renderer": "15.3.2"
  },
  "rnpm": {
    "assets": [
      "./assets/fonts"
    ]
  }
}

index.android.js

import React, { AppRegistry } from 'react-native';
import AppProvider from './src/index';
AppRegistry.registerComponent('AwesomeLeadership', () => AppProvider);

index.js

import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import { Provider } from 'react-redux';
import { persistStore, autoRehydrate } from 'redux-persist';
import store from './app/appStore';
import AppContainer from './app/appContainer';
import Splashscreen from './app/splashScreen';
import I18n from './app/i18n';
import SwipUnlocker from './app/SwipeUnlocker';

const Orientation = require('react-native-orientation');

class AwesomeLeadership extends Component {
  render() {
    return <AppContainer /> ;
  }
}

class AppProvider extends Component {
  constructor(props) {
    super(props);
    this.state = {
      isInitializing: true,
    }
  }

  componentDidMount() {
    Orientation.lockToPortrait();
    const unsubscribe = store.subscribe(() => {
      if (store.getState().isHydrated) {
        unsubscribe();
        I18n.locale = 'sv-SE';
        this.setState({
          isInitializing: false,
        });
      }
    });
  }

  render() {
    if(this.state.isInitializing) {
      return <Splashscreen/>;
    } else {
      return (
        <Provider store={store}>
          <AwesomeLeadership/>
        </Provider>
      );
    }
  }
}

export default AppProvider;

enter image description here

2 个答案:

答案 0 :(得分:2)

我有同样的错误,我相信它与不同版本的React和React Native有关。

例如,RN 0.51需要React 16.0的对等依赖性。在我的情况下,我有16 alpha并导致错误。我建议你尝试安装相应版本的React。

希望它有所帮助。

答案 1 :(得分:0)

我遇到同样的错误...... 我只是将react-native版本更改为0.49.0。工作得很好。

相关问题