Import & export

1
why the Provider imported module is inside of curly braces? and the React, ReactDOM are no curly braces?

  1. Import all exports into current module scope β€” import * from "my-module.js"
  2. Import particular named exports β€” import { func1, obj2 } from "my-module.js"
  3. Import the default export β€” import func from "my-module.js"
  4. Run a module’s global code but not import anything β€” import "my-module.js"
  5. Dynamic importing a module β€” import("my-module.js").then((module) => { //...do something })

Source and Read more about imports in JavaScript

1 Like

React is the default export of 'react'.
ReactDOM is the default export of 'react-dom'.
Provider is not the default export of 'react-redux'.

1 Like

for Default Export

import person from './person.js'

or

import per from './person.js'

Imports default and only export of the imported file. We can give any name.


for Named Export

import {calSal} from './actions.js'
import {baseSal} from './actions.js'

Need to specify the export name you are importing from the file.


You can import all the named exports as a bundle from a file as follow

import * as all_actions from './actions.js'`
1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.