当前位置 : 主页 > 网页制作 > React >

react-native iterator typeof符号错误

来源:互联网 收集:自由互联 发布时间:2021-06-15
TypeError:undefined不是函数(评估’iteratortypeof Symbol ===’函数“?Symbol.iterator:”@@ iterator“’) 我还没写太多代码.我刚刚导入了router-flux和redux(以及有关redux的东西).应用程序正在iOS上工作
TypeError:undefined不是函数(评估’iteratortypeof Symbol ===’函数“?Symbol.iterator:”@@ iterator“’)

我还没写太多代码.我刚刚导入了router-flux和redux(以及有关redux的东西).应用程序正在iOS上工作,没有问题.也在Android上工作,但只有调试模式.我无法解决它.

这是我的package.json文件;

{
  "name": "newProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "firebase": "^5.3.0",
    "lodash": "^4.17.10",
    "react": "16.4.1",
    "react-native": "0.56.0",
    "react-native-router-flux": "^4.0.0-beta.31",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "babel-jest": "23.4.0",
    "babel-preset-react-native": "^5",
    "jest": "23.4.1",
    "react-test-renderer": "16.4.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

这是App呈现的第一个页面;

import React, { Component } from 'react';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import ReduxThunk from 'redux-thunk';
import reducers from './reducers';
import Router from './Router';

class Main extends Component {
  componentWillMount() {
      const firebase = require('firebase');
    firebase.initializeApp({
        apiKey: "AIzaSyDFO_Rfas36L8R8p6qxTvCr843ajeamoMs",
        authDomain: "helloworld-e510b.firebaseapp.com",
        databaseURL: "https://helloworld-e510b.firebaseio.com",
        projectId: "helloworld-e510b",
        storageBucket: "helloworld-e510b.appspot.com",
        messagingSenderId: "316625723749"
  });
  }
  render() {
    const store = createStore(reducers, {}, applyMiddleware(ReduxThunk));
    return (
      <Provider store={store}>
        <Router />
      </Provider>
    );
  }
}

export default Main;

最后这是路由器页面;

import React from 'react';
import { Scene, Router, Actions } from 'react-native-router-flux';
import MainPage from './components/MainPage';

const RouterComponent = () => {
    return (
      <Router>
      <Scene key="main">
        <Scene key="mainPage" title="Giriş" component={MainPage} />
      </Scene>
      </Router>
    );
};

export default RouterComponent;

我在github和这里搜索过但我找不到足够好的解决方案.我希望有人能帮帮忙.

我遇到了这个问题,以下解决方案有效.
将以下行粘贴到您的app.js文件中的本机项目中.

// symbol polyfills
global.Symbol = require('core-js/es6/symbol');
require('core-js/fn/symbol/iterator');

// collection fn polyfills
require('core-js/fn/map');
require('core-js/fn/set');
require('core-js/fn/array/find');

有关更多信息,请参阅以下问题
https://github.com/facebook/react-native/issues/15902#issuecomment-375521246

网友评论