store.js
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')
);
Folder src consist index.js and store.js
Show message Uncaught TypeError: (0 , _store.configureStore) is not a function when F12
Help me thanks
Edited on March 11th 2019:
This answer will likely no longer work. Please see discussion in comments below as to why, and what should be the actual solution.
You export a single function from your module, so your import should be:
import configureStore from './store';
You would use
import {configureStore} from './store';
if your export looked like
export default {
configureStore: function(initialState) {
return createStoreWithMiddleware(rootReducer, initialState);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With