使用expo生成的react本机应用程序时,当我尝试导出reducer并将其导入到我的商店时遇到问题。
一切都进展顺利,直到我决定将另一个reducer添加到我的reducer导出文件中,然后出现此错误。
t["function"==typeof Symbol?Symbol.iterator:"@@iterator"] is not a function.
经过研究后,我发现它与Symbol.iterator不是函数有关,并且与我的babel实现有关。
我尝试过: https://github.com/facebook/immutable-js/issues/1305 https://github.com/facebook/react-native/issues/15902
将我的最新回购推送到此处:
https://github.com/AgSpine-Group/rn-agspine-app
Package.json看起来像这样:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject",
"test": "node ./node_modules/jest/bin/jest.js --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/samples": "2.1.1",
"@expo/vector-icons": "^9.0.0",
"axios": "^0.18.0",
"expo": "^32.0.0",
"native-base": "^2.10.0",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-vector-icons": "^6.2.0",
"react-navigation": "^3.0.9",
"react-redux": "^6.0.0",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-persist": "^5.10.0",
"redux-promise-middleware": "^5.1.1",
"redux-thunk": "^2.3.0",
"uuid-v4": "^0.1.0"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"babel-preset-expo": "^5.0.0",
"install": "^0.12.2",
"jest-expo": "^32.0.0",
"npm": "^6.7.0"
},
"private": true
}
babel配置看起来像这样:
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
store.js文件为:
import { createStore, applyMiddleware, compose } from 'redux';
import rootReducer from '../reducers';
import logger from 'redux-logger';
import thunk from 'redux-thunk';
import { AsyncStorage } from 'react-native';
import { persistStore, persistCombineReducers, persistReducer } from 'redux-persist'
const persistConfig = {
storage: AsyncStorage,
key: 'root',
}
const persistedReducer = persistCombineReducers(persistConfig, rootReducer);
const middleware = compose(applyMiddleware(
thunk,
logger,
), window.devToolsExtension ? window.devToolsExtension() : f => f);
export default () => {
const store = createStore(persistedReducer, {}, middleware);
const persistor = persistStore(store);
return { store, persistor };
}
我的减速器索引文件是:
import items from './items';
import form from './form';
export default { items, form };
当我进口形式和导出的问题就出现了。
我还尝试将导出更改为:
export { items, form };