Even Stensberg
Even Stensberg

Reputation: 508

Connect component not rendering props correctly

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);

Upvotes: 1

Views: 75

Answers (1)

U r s u s
U r s u s

Reputation: 6968

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'

Upvotes: 4

Related Questions