in React, what is the difference between these two:
import {history} from '../../app/setup.js';
import history from '../../app/setup.js';
in React, what is the difference between these two:
import {history} from '../../app/setup.js';
import history from '../../app/setup.js';
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
.