ES6 the best way to import Import named import

I was wondering which of the two ways to import React named import ( PropTypes, Component) into ES6 is the best.

First

import React, {PropTypes, Component} from 'react';

to save a lot of typing specifically for components that have a lot of details for verification.

Second

import React form 'react';

and then call them like React.Componentwhen I want to use them.

Is there a performance difference between the two approaches or should I just choose whichever style is it more convenient for me?

+4
source share
2 answers

I would say that the difference in performance is almost zero.

: , , , lodash -

import { map } form 'lodash';
import { map } from 'underscore'; // oh no map-clash

import lodash from 'lodash';
import underscore from 'underscore'; // lodash.map v underscore.map

( {}), "" , , , .

, , , - ES6.

, map lodash, :

import map from 'lodash/map';

:

import { map } from 'lodash';

( browseifry/rollup/webpack/[insert flavor of the month]), , . .

+1

, - .


React , , .

import React from 'react';

class Welcome extends React.Component { ... }
+2

Source: https://habr.com/ru/post/1670030/


All Articles