'store'应列在项目的依赖项
中
出于某种原因,我无法将我的商店导入App.js
在这里你可以看到App.js和store.js处于同一级别:
App.js
import React from 'react';
import { connect, Provider } from 'react-redux';
import Routes from './config/Routes';
import { setSearch } from './actions';
import localCoins from './coins.json';
// Store
import store from 'store';
class App extends React.Component {
componentWillMount() {
this.props.setSearch(localCoins);
}
render() {
return (
<Provider store={store}>
<Routes />
</Provider>
);
}
}
const mapDispatchToProps = dispatch => ({
setSearch: (...args) => { dispatch(setSearch(...args)); }
});
export default connect(null, mapDispatchToProps)(App);
store.js
import { createStore, combineReducers, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
// Reducers
import reducers from './reducers';
/* eslint-disable no-underscore-dangle */
const reduxDevToolsExtension = window.__REDUX_DEVTOOLS_EXTENSION__;
/* eslint-enable */
const store = createStore(
combineReducers({
...reducers
}),
reduxDevToolsExtension && reduxDevToolsExtension(),
applyMiddleware(
thunk
)
);
export default store;
答案 0 :(得分:1)
你的意思是import store from './store';
您缺少表示项目文件不是已安装依赖项的./