0

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

import { appReducers } from './reducers/index'

const Store = () => {
  console.log(appReducers);
}

export default Store

in index.js

const appReducers = "hello world";
export default appReducers

in app.js

import React, { useState, useEffect, useMemo } from 'react';
import Store from './redux'

function App() {
  Store();
  return (
    <div>

    </div>
  );
}

export default App;
2
  • import { appReducers } from That does not import the default.. That syntax is for importing something called appReducers, if you want the default remove the {}
    – Keith
    Sep 5, 2022 at 14:59
  • Thanks, i can't believe I didn't know the difference until now
    – David Tran
    Sep 6, 2022 at 9:25

1 Answer 1

3

The problem is in redux.js. Instead of

import { appReducers } from './reducers/index'

You need

import appReducers from './reducers/index'

What you were doing before was a named import, not a default import.

1
  • omg that's such a stupic mistake, thanks for your reply
    – David Tran
    Sep 6, 2022 at 9:23

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.