I'm bulding App with React Redux.
This is my reducer:
import { INCOME_LIST } from '../actionTypes'
import Immutable from 'immutable'
const initialUserState = {
list: [{
id: 1,
label: 'List item 1'
},
{
id: 2,
label: 'List item 2'
}]
}
const listReducer = function(state = [initialUserState], action) {
switch(action.type) {
case 'INCOME_LIST':
return Object.assign({}, state, { list: action.data });
default: return state;
}
}
export default listReducer
This is my Component:
import React, { Component, PropTypes } from 'react'
import { Link, browserHistory } from 'react-router'
import { connect } from 'react-redux'
import axios from 'axios'
class Income extends Component {
constructor(props) {
super(props)
}
}
render() {
console.log(this.props.items)
return (
<div>
test
</div>
)
}
}
const mapStateToProps = function(store) {
return {
items: state.list
};
}
export default connect(mapStateToProps)(Income);
Console says that: 'undefined' Why console.log(this.props.items) get undifined? How to right way to get a state from reducer? May be mistake there?