I am new with redux
, react
and parceljs
. I'm currently experimenting with this 3 stuff by doing the redux tutorial
. And after parceljs
did it job, when I went to the browser I got this error on the console:
Uncaught TypeError: (0 , _reactRedux.connect) is not a function
The code right now is
import { connect } from 'react-redux';
const AddTodo = ({dispatch}) => {
.
.
.
}
export default connect()(AddTodo)
I changed:
import { connect } from 'react-redux';
to:
import { connect } from 'redux';
and gave me basically same error.
What should I do in this case?
I checked the documentation and issues and the only issues I found about connect()
is that you cannot use it as a decorator but that's it. Am I missing something I don't know yet?
(Sorry for my bad grammar in English, not my first language)
I am new with redux
, react
and parceljs
. I'm currently experimenting with this 3 stuff by doing the redux tutorial
. And after parceljs
did it job, when I went to the browser I got this error on the console:
Uncaught TypeError: (0 , _reactRedux.connect) is not a function
The code right now is
import { connect } from 'react-redux';
const AddTodo = ({dispatch}) => {
.
.
.
}
export default connect()(AddTodo)
I changed:
import { connect } from 'react-redux';
to:
import { connect } from 'redux';
and gave me basically same error.
What should I do in this case?
I checked the documentation and issues and the only issues I found about connect()
is that you cannot use it as a decorator but that's it. Am I missing something I don't know yet?
(Sorry for my bad grammar in English, not my first language)
Share Improve this question edited Jul 23, 2018 at 18:34 Josue Toledo asked Jul 23, 2018 at 17:52 Josue ToledoJosue Toledo 3592 gold badges3 silver badges8 bronze badges 5- AddTodo doesn't seem to be a ponent and you aren't supplying anything to connect. Also are you sure you have install react-redux npm package – Shubham Khatri Commented Jul 23, 2018 at 17:55
- code seems correct. Post AddTodo – Shubham Agarwal Bhewanewala Commented Jul 23, 2018 at 17:56
- it is not necessary to supply anything to connect @ShubhamKhatri isnt it? – Shubham Agarwal Bhewanewala Commented Jul 23, 2018 at 17:57
- const AddTodo = (props) => {} AddTodo is supposed to be like this – Shubham Agarwal Bhewanewala Commented Jul 23, 2018 at 17:59
- @ShubhamAgarwalBhewanewala, no it doesn't require any arguments but it requires a ponent which is binded – Shubham Khatri Commented Jul 23, 2018 at 18:06
1 Answer
Reset to default 5To use connect, you need to bind the ponent not an object. Thus, you may change your todo
const AddTodo = {
With:
const AddTodo = () => { // a stateless ponent
// now, you can return the object
return ( // just an example
<div>
<input type="text" />
</div>
)
}
And the connect is imported from react-redux:
import { connect } from 'react-redux'; // this is correct