gpt4 book ai didi

react-native iterator typeof Symbol 错误

转载 作者:行者123 更新时间:2023-12-04 04:20:56 27 4
gpt4 key购买 nike

TypeError: undefined is not a function (evaluating 'iteratortypeof Symbol === "function"? Symbol.iterator : "@@iterator"')

This is the error i get.

我还没有写太多行代码。我刚刚导入了 router-flux 和 redux(以及关于 redux 的东西)。应用程序在 iOS 上运行,问题为零。也在 android 上工作,但只能使用 Debug模式。我无法解决它。

这是我的 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和here上搜索过,但找不到足够好的解决方案。我希望有人能帮帮忙。

最佳答案

我遇到了这个问题,下面的解决方案有效。
将以下几行粘贴到 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

关于react-native iterator typeof Symbol 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51459812/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com