我已经开始使用React-Native并运行iOS。 我正在创建一个基于f8App的应用程序,该应用程序在github中共享,但升级到最新的依赖项。
我也在使用Redux来运行这个应用程序。在这种情况下,最初的目标是加载将使用firebase Auth。
的登录页面以下是setup.js
:
/**
* @flow
*/
'use strict';
import React, { Component } from 'React';
import {Provider} from 'react-redux';
import AsistenciaApp from './AsistenciaApp';
import {configureStore} from './store/configureStore';
function setup(): ReactClass<{}> {
class Root extends Component {
state: {
isLoading: boolean;
store: any;
};
constructor() {
super();
this.state = {
isLoading = true,
store:
configureStore(
() => this.setState({isLoading: false})
)
};
}
render() {
if (this.state.isLoading) {
return null;
}
return (
<Provider store={this.state.store}>
<AsistenciaApp />
</Provider>
);
};
}
return Root;
}
module.exports setup;
当我运行react-native run-ios
时,我收到以下错误:
Syntax Error setup.js Unexpected token, expected, (25,30)
指向此函数的configureStore
,下面我附上该文件的代码:
/**
*
* @flow
*/
'use strict';
import {applyMiddleware, createStore} from 'redux';
import thunk from 'redux-thunk';
import promise from './promise';
import array from './array';
import {createLogger} from 'redux-logger';
import reducers from '../reducers';
import {persistStore, autoRehydrate} from 'redux-persist';
import {AsyncStorage} from 'react-native';
let isDebuggingInChrome = __DEV__ && !!window.navigator.userAgent;
let logger = createLogger({
predicate: (getState, action) => isDebuggingInChrome,
collapsed: true,
duration: true,
});
let createD4mStore = applyMiddleware(thunk, promise, array, logger)(createStore);
function configureStore(onComplete: ?() => void) {
const store = autoRehydrate()(createD4mStore)(reducers);
persistStore(store, {storage: AsyncStorage}, onComplete);
if (isDebuggingInChrome) {
window.store = store;
}
return store;
}
module.exports = configureStore;
我做错了什么?
答案 0 :(得分:0)
您已将configureStore
导出为default
。替换:
import {configureStore} from './store/configureStore';
与
import configureStore from './store/configureStore';
或导出configureStore
为export
。替换:
module.exports = configureStore;
与
export configureStore;