0

in React, what is the difference between these two:

import {history} from '../../app/setup.js';

import history from '../../app/setup.js';
halfer
  • 19,471
  • 17
  • 87
  • 173
AnApprentice
  • 103,298
  • 185
  • 610
  • 989
  • Possible duplicate of [in reactjs, when should I add brackets when import](https://stackoverflow.com/questions/41337709/in-reactjs-when-should-i-add-brackets-when-import) – Shubham Khatri Jun 13 '17 at 04:40

1 Answers1

2

It depends on the package's export format. If setup.js sets a default export, like

// setup.js
export default history

Then import history from … would pick it up. This syntax will assign the entire export from setup.js to history in your current module.

If the export is like this:

// setup.js
export { history }

Then import {history} from … would pick it up. This syntax is looking for a .history property in the module exported from setup.js.

FeifanZ
  • 16,108
  • 6
  • 46
  • 80