ES6 Destructuring and Module imports

后端 未结 2 1497
感情败类
感情败类 2020-11-27 15:55

I was under the impression that this syntax:

import Router from \'react-router\';
var {Link} = Router;

has the same final result as this:

2条回答
  •  感情败类
    2020-11-27 16:24

    To do this:

    import {purple, grey} from 'themeColors';
    

    Without repeating export const for each symbol, just do:

    export const
      purple = '#BADA55',
      grey = '#l0l',
      gray = grey,
      default = 'this line actually causes an error';
    

提交回复
热议问题