最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React & Redux: Uncaught TypeError: (0 , _reactRedux.connect) is not a function - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 5

To 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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论