Not sure if you got the answer to this already but you can export it as:-
export default {
STATES: {
'AU' : {...},
'US' : {...}
}
};
to which you can import as:-
import STATES from 'states';
or
var STATES = {};
STATES.AU = {...};
STATES.US = {...};
export STATES;
to which you can import as:-
import { STATES } from 'states';
Notice the difference between one that uses default and one that doesn’t. With default you can export any javascript expression and during import you can use whatever identifier and it will be defaulted to that default expression.
You could also have done
import whatever from 'states';
and whatever would get the value of an object that we assigned to default.
In contrast, when you don’t export default expression, export exports it as an part of object which is why you had to use
import {STATES}
In this case you HAVE to use the right literal name for import to work or else import will not be able to understand what you’re trying to import. Also, note that it’s using object destructuring to import the right value.
And like @AlexanderT said, there are ways to import as * too, in fact there are various ways to import and export but I hope I explained the core concept of how this import/export works.