无法将我的商店文件导入App.js错误:'store'应列在项目的依赖项中

时间:2017-12-06 00:33:57

标签: javascript reactjs redux react-redux

  

'store'应列在项目的依赖项

出于某种原因,我无法将我的商店导入App.js

enter image description here

在这里你可以看到App.js和store.js处于同一级别:

enter image description here

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;

1 个答案:

答案 0 :(得分:1)

你的意思是import store from './store';

您缺少表示项目文件不是已安装依赖项的./