it-swarm.com.de

Reaktiver Absturz unter iOS mit der Reaktionsnavigation

Ich bekomme nur unter iOS eine Fehlermeldung:

TypeError: undefined is not an object (evaluating 'this._callListeners.bind')

This error is located at:
  in DrawerLayout (at DrawerView.js:161)
  ...

Projektabhängigkeiten:

"dependencies": {
    "@babel/runtime": "7.2.0",
    "@babel/plugin-proposal-async-generator-functions": "7.2.0",
    "@babel/plugin-proposal-class-properties": "7.2.1",
    "@babel/plugin-proposal-object-rest-spread": "7.2.0",
    "babel-preset-expo": "5.0.0",
    "expo": "31.0.2",
    "expo-cli": "2.5.0",
    "native-base": "2.8.1",
    "react": "16.6.3",
    "react-native": "0.57.8",
    "react-redux": "6.0.0",
    "react-navigation": "3.0.8",
    "react-native-vector-icons": "6.1.0",
    "redux": "4.0.1"
  }

Dies begann, als ich mit der reag-navigation anfing. funktioniert aber gut auf Android.

Hier ist der Code, mit dem wir reagieren-navigation verwenden. Dies ist die Haupt-App, die beim Importieren die Bildschirme "Startseite" und "Einstellungen" umfasst:

//imports...

const routes = {
  Home: Home,
  Settings: Settings
};

const AppNavigator = createDrawerNavigator(routes);

const AppContainer = createAppContainer(AppNavigator);

export default class App extends React.Component {
  state = {}

  render() {
    if (this.state.isReady) {
      return (
        <AppContainer/>
      );
      }
      else {
        return (<Container><Spinner/></Container>);
      }
  }

  componentWillMount() {
    this._loadAssets();
  }

  async _loadAssets() {
    await Expo.Font.loadAsync({
      Roboto: require("native-base/Fonts/Roboto.ttf"),
      Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf")
    });

    this.setState({ isReady: true });
  }
}
5
Patrick Dench

Ich konnte das endlich zum Laufen bringen, nachdem ich viele Lösungsmöglichkeiten durchlaufen hatte.

Anscheinend hatte ich einige Probleme - mit Paketversionskonflikten und der .babelrc-Konfiguration.

Mit diesen konnte ich loslegen ..

package.json deps:

"dependencies": {
    "@babel/plugin-proposal-async-generator-functions": "7.2.0",
    "@babel/plugin-proposal-class-properties": "7.2.1",
    "@babel/plugin-proposal-decorators": "7.2.0",
    "@babel/plugin-proposal-object-rest-spread": "7.2.0",
    "@babel/plugin-transform-runtime": "7.2.0",
    "@babel/runtime": "7.2.0",
    "@react-navigation/core": "3.0.2",
    "@react-navigation/native": "3.1.0",
    "babel-preset-expo": "5.0.0",
    "expo": "31.0.6",
    "native-base": "2.10.0",
    "react": "16.5.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
    "react-native-vector-icons": "6.1.0",
    "react-navigation": "3.0.9",
    "react-navigation-drawer": "1.0.5",
    "react-redux": "6.0.0",
    "redux": "4.0.1"
  }

Und .babelrc in meinem Hauptverzeichnis:

{
  "presets": ["babel-preset-expo"],
  "plugins": [
    ["module-resolver", {
      "root": ["./"],
      "alias": {
        "_framework": "./framework",
        "_apps": "./apps"
      }
    }]
  ]
}
0
Patrick Dench

Ich habe diesen Fehler behoben, indem ich folgende Änderung an meinem .babelrc vorgenommen habe.

{
  "presets": ["module:metro-react-native-babel-preset"],
  "plugins": [
-    ["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true }]
+    ["@babel/plugin-proposal-decorators", { "legacy": true }]
  ]
}

Mein package.json:

"dependencies": {
    "axios": "^0.18.0",
    "mobx": "^5.8.0",
    "mobx-react": "^5.4.3",
    "react": "16.6.3",
    "react-native": "0.57.8",
    "react-native-device-info": "^0.24.3",
    "react-native-elements": "^1.0.0-beta5",
    "react-native-haptic-feedback": "^1.3.0",
    "react-native-svg": "^8.0.10",
    "react-native-vector-icons": "^6.0.2",
    "react-navigation": "^3.0.9",
    "rollbar-react-native": "^0.4.0"
  },
"devDependencies": {
    "@babel/core": "^7.2.2",
    "@babel/plugin-proposal-decorators": "^7.2.3",
    "babel-eslint": "^10.0.1",
    "babel-jest": "23.6.0",
    "eslint": "^5.12.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.2",
    "eslint-plugin-react": "^7.12.3",
    "eslint-plugin-react-native": "^3.5.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.51.1",
    "react-test-renderer": "16.6.3"
  }
0
Jasdeep Singh