I was under the impression that this syntax:
import Router from 'react-router';
var {Link} = Router;
has the same final result as this:
import {Link} from 'react-router';
Can someone explain what the difference is?
(I originally thought it was a React Router Bug.)
To do this:
Without repeating
export const
for each symbol, just do:imports a named export from
react-router
, i.e. something likepulls out the property
Link
from the default export, assuming it is an object, e.g.(the default export is actually nothing but a standardized named export with the name "default").
See also
export
on MDN.Complete example:
With Babel 5 and below I believe they have been interchangeable because of the way ES6 modules have been transpiled to CommonJS. But those are two different constructs as far as the language goes.