osmancakirio
osmancakirio

Reputation: 519

importing connect function from 'react-redux'

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

Answers (3)

Eloi
Eloi

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

user16442705
user16442705

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

TheRakeshPurohit
TheRakeshPurohit

Reputation: 551

connect is not the default export. Use as below. import { connect } from "react-redux";

example

Upvotes: 0

Related Questions