1

I'm having a bit of an issue with Redux, as I'm trying to wrap my with connect(). Consider all imports valid(as they are). Here's the source code along with the output error. bad error :((

import React, { Component } from 'react'
import { connect, bindActionCreators } from 'react-redux'
import * as counterActionCreators from '../core/actionCreators/count'

class CounterEgg extends Component {
  render() {
    const { onIncrement, store } = this.props
    let { value } = this.props
    value = store.getState()

    return (
      <div>
        Clicked: {value} times
        {' '}
        <button onClick={onIncrement}>
          +
        </button>
      </div>
    )
  }
}
function mapDispatchToProps(dispatch) {
  return {
    onIncrement: bindActionCreators(counterActionCreators, dispatch)
  }
}

export default connect(null, mapDispatchToProps)(CounterEgg);
2
  • I'm using webpack 2.0, FWIW Commented Jun 22, 2016 at 12:02
  • I'm also subscribing the store through provider. Commented Jun 22, 2016 at 12:04

1 Answer 1

4

One of your import is actually not valid:

import { connect, bindActionCreators } from 'react-redux'

bindActionCreators is part of redux, not react-redux.

So you should have

import { connect } from 'react-redux'

import { bindActionCreators } from 'redux'

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks U r s u s !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.