2
store.js未捕獲的類型錯誤:(0,_store.configureStore)不是函數
import {createStore, applyMiddleware} from 'redux';
import createLogger from 'redux-logger';
import rootReducer from './reducers/index';
const logger = createLogger();
const createStoreWithMiddleware = applyMiddleware(logger)(createStore);
export default function configureStore(initialState) {
return createStoreWithMiddleware(rootReducer, initialState);
}
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import TrackList from './components/TrackList';
import {configureStore} from './store';
import * as actions from './actions';
const tracks = [
{
id: 1,
title: 'Title 1'
},
{
id: 2,
title: 'Title 2'
}
];
const store = configureStore();
store.dispatch(actions.setTracks(tracks));
ReactDOM.render(
<TrackList />,
document.getElementById('app')
);
文件夾的src由index.js和store.js
顯示消息Uncaught TypeError:(0,_store.configureStore)不是函數時F12
幫我謝謝
非常感謝你很多,我是新手REDX,再次感謝 –
最終'出口默認{...'實際上不再工作。根據規格,您現在必須按名稱出口。導出應該是'export function configureStore(initialState){...}'。 – DDS
@HieuBui請注意,這是一個與Redux無關的ES6問題。 – DDS