I am converting some ES5 code to ES6.
I have the following line somewhere in the file StatesComponent.js
const STATES = require('../data/states.js');
I am using jspm and it doesn't support require
, so I would like to use ES6 import
syntax instead.
The states.js
file contains the following:
exports.AU = [
{ value: 'australian-capital-territory', label: 'Australian Capital Territory', className: 'State-ACT' },
{ value: 'new-south-wales', label: 'New South Wales', className: 'State-NSW' },
{ value: 'victoria', label: 'Victoria', className: 'State-Vic' },
];
exports.US = [
{ value: 'AL', label: 'Alabama', disabled: true },
{ value: 'AK', label: 'Alaska' },
{ value: 'AS', label: 'American Samoa' },
];
STATES
variable is being used as var options = STATES[this.state.country];
How do I change the format of the json in states.js
such that I can `import' it?
i.e import STATES from '../data/states'
import * as STATES from '../data/states.js'
;