Why when I use export default on index.js module it says: export ‘appReducers’ (imported as ‘appReducers’) was not found in ‘./reducers/index’ (possible exports: default), but when I change it to module.exports the error go away, why is that?
At redux.js
JavaScript
x
8
1
import { appReducers } from './reducers/index'
2
3
const Store = () => {
4
console.log(appReducers);
5
}
6
7
export default Store
8
in index.js
JavaScript
1
4
1
const appReducers = "hello world";
2
export default appReducers
3
4
in app.js
JavaScript
1
14
14
1
import React, { useState, useEffect, useMemo } from 'react';
2
import Store from './redux'
3
4
function App() {
5
Store();
6
return (
7
<div>
8
9
</div>
10
);
11
}
12
13
export default App;
14
Advertisement
Answer
The problem is in redux.js
. Instead of
JavaScript
1
2
1
import { appReducers } from './reducers/index'
2
You need
JavaScript
1
2
1
import appReducers from './reducers/index'
2
What you were doing before was a named import, not a default import.