0

in React, what is the difference between these two:

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

import history from '../../app/setup.js';
halfer
  • 19,824
  • 17
  • 99
  • 186
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
  • 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,250
  • 7
  • 45
  • 84