I just started learning Redux and having a tough time managing state. The code snippets are mentioned below :
TestComponent.js
class TestComponent extends React.Component {
componentDidMount() {
// Mounts component
}
render() {
<div>
{console.log("Inside div")}
{console.log(this.props.item2)} // Get undefined here
<button onClick = {() => create(1, this.props.item2)}></button>
</div>
}
const dispathToPropertyMapper = dispatch => {
return {
create: (id, item2) => {
// Does somthing
}
const stateToPropertyMapper = state => {
return {
item1: state.state1.item1,
item2: state.state2.item2
};
};
myReducer.js
const initialState = {
item1: [],
item2: "Sample Text"
};
const myReducer= (state = initialState, action) => {
console.log(action.type);
switch (action.type) {
return state;
}
I have done all the exports and imports correctly. I am getting the props for item 1 which is an empty array but I am getting undefined for the prop item2. This is my first time using redux and spent a lot of time on this. Please help Thanks in adv