Reputation: 519
I have a short legacy code question about importing connect tag from react-redux
module. I have seen in a repo it is imported as import connect from 'react-redux/es/connect/connect'
not as import { connect } from 'react-redux'
Do you know why the former developer imported it like that? Everything is working fine but I would like to find out if there is an advantage importing it like that.
Upvotes: 1
Views: 294
Reputation: 476
It is the same, is just that before we could not use { }
to import like import { connect } from 'react-redux'
so the options were importing all the library or finding a specific file in the folders with an export so you can import connect from 'react-redux/es/connect/connect'
Edit: I just realised that curly braces for declaring variables were introduced at the same time that import
, so I don't know why anyone would do that, but of course still works.
Upvotes: 2
Reputation:
I'd guess it's because they didn't know exactly what they were doing, or they had some intellisense suggest it and just left it without making it more conventional.
Upvotes: 0
Reputation: 551
connect
is not the default export. Use as below.
import { connect } from "react-redux";
Upvotes: 0