0

I've come across code like this:

import React, { Component } from 'react';

What is the difference between that and this:

import { React, Component } from 'react';

I have rarely seen anything outside the curly braces.

Johann
  • 24,056
  • 38
  • 149
  • 245
  • 1
    Does this answer your question? [What is use of Curly Braces in ES6 import statement](https://stackoverflow.com/questions/41337709/what-is-use-of-curly-braces-in-es6-import-statement) – Rashomon Mar 06 '20 at 09:11
  • 1
    This first imports the default of 'react' as React, the second imports the named export React – OliverRadini Mar 06 '20 at 09:11
  • I don't think there is a difference. `React` is probably the default export which should coincide with the other named export. – VLAZ Mar 06 '20 at 09:12
  • @OliverRadini You are correct. I came across this: https://stackoverflow.com/a/36796281/753632 I initially thought it had something to do with destructuring. – Johann Mar 06 '20 at 09:13
  • @AndroidDev Good ol' Dan Abramov! – OliverRadini Mar 06 '20 at 09:15
  • Obligatory MDN link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import – Felix Kling Mar 06 '20 at 09:40

1 Answers1

0

This first imports the default of 'react' as React, the second imports the named export React

OliverRadini
  • 5,753
  • 1
  • 17
  • 40