When I put console.log('test') statements in my reducer, I can see them in the console when the actions are called. But I'm not seeing the redux "NEXT STATE"/ "PREV STATE" stuff in the console.
Is there anything basic I could be missing?
In the code below - I'm not trying to make any real functionality happen, I'm just trying to setup redux and see the state change in the console (so I know I'm on the correct path).
Container
import React, { PropTypes } from 'react-native';
import Header from './Header';
import { connect } from 'react-redux';
import { leave } from './actions';
import { join } from './actions';
const mapStateToProps = (state) => {
return {
in: state.in
}
}
const mapDispatchToProps = (dispatch) => {
return {
join: (id) => {
dispatch(join(id))
},
leave: (id) => {
dispatch(leave(id))
}
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Header);
Reducer
export default function Header(state = { in: false }, action = {}) {
switch (action.type) {
case 'LEAVE':
return {
...state,
in: false
}
case 'JOIN':
console.log(state);
console.log(action);
console.log('join');
return {
...state,
in: true
}
default:
return state;
}
}
Actions
export const join = (id) => {
return {
type: 'JOIN',
payload: {
in: true
}
}
}
export const leave = (id) => {
return {
type: 'LEAVE',
payload: {
in: false
}
}
}
It solved when I realized that https://github.com/fcomb/redux-logger is needed to be installed separately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With