Steven Song
Steven Song

Reputation: 71

Warning : Assign object to a variable before exporting as module default

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?

Upvotes: 5

Views: 14286

Answers (1)

Ashkan
Ashkan

Reputation: 876

There 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.

Upvotes: 11

Related Questions