TypeError:未定义不是函数(计算'iteratortypeof Symbol ===“ function”?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和这里进行了搜索,但是找不到足够好的解决方案。我希望有人能提供帮助。
答案 0 :(得分:7)
我遇到了这个问题,以下解决方案有效。 将以下行粘贴到react native项目的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
答案 1 :(得分:1)
我遇到了这个问题,并提出了不同的解决方案。我正在做一个for-of循环,结果发现我循环通过的数组有时为空。
let matched = input.match(regex);
for (let m of matched) {
// ...
}
我没有意识到如果找不到匹配项,String.prototype.match()
将返回null。我以为它只会返回一个空数组。我收到的错误根本没有指向这个方向,但是一旦我意识到了这个错误,就可以解决问题。