I'm using react-redux, and this is my root Reducer:
import Customers from "./customers/reducer";
export default {
Customers
};
but I got this warning: Assign object to a variable before exporting as module default. How do I deal with it?
I'm using react-redux, and this is my root Reducer:
import Customers from "./customers/reducer";
export default {
Customers
};
but I got this warning: Assign object to a variable before exporting as module default. How do I deal with it?
Share Improve this question asked Nov 13, 2020 at 6:51 Steven Song Steven Song 711 gold badge1 silver badge3 bronze badges 4-
Shouldn't this be
export default Customers
? – VLAZ Commented Nov 13, 2020 at 6:55 - Right now, I just import one module, but later I will import more modules. While I tried your suggestion. That works. Thank you. – Steven Song Commented Nov 13, 2020 at 7:06
- If you want to re-export multiple things, then you likely want them as regular exports, not default ones. – VLAZ Commented Nov 13, 2020 at 7:09
-
@StevenSong If you import it only to export again (like an index.js collecting from othr files) you could do:
export { default as Customers} from "./customers/reducer";
– HMR Commented Nov 13, 2020 at 8:37
1 Answer
Reset to default 11There are some solutions:
1- Disable the warning
import Customers from "./customers/reducer";
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
export default {
Customers
};
2- create a const then export it
import Customers from "./customers/reducer";
const aName = {
Customers
};
export default aName;
Read this descriptions For more information.