javascript - import React, { Component } from 'react'; What is the {} part? -


pretty simple, can explain me part between curly braces is?

i understand add , can remove react "extends react.component" not sure use of or reasoning behind it.

it allows import single member if require. in case provided may not useful other ones. example:

// constants.js export const test_const = 'hola'; export const other_test_const = 'yo';  // somefile.js import { test_const } './constants';  console.log(test_const); // output: 'hola' 

hope helps little. theres great description of module system on mdn.

https://developer.mozilla.org/en-us/docs/web/javascript/reference/statements/import


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -