Help to understand why the state of the store does not accumulate. I'm doing a twitter-like app. In the store I want to add posts. And the store constantly resets its state. I do not think where you need to correct the code. After all, they write in the official docks: (previousState, action) => newState, although the store there is stored in an array, and not in a literal like mine: http://redux.js.org/docs/basics/Reducers.html
My application is entirely here: https://github.com/SkunSHD/redux-twitter-like-app/tree/master
The reducer code looks like this: reducers / page.js
import { ADD_POST, ADD_COMMENT, LOGIN_SUCCES } from '../constants/Page' const initialState = { user: '', text: '' } export default function page(state = initialState, action) { switch (action.type) { case LOGIN_SUCCES: return { ...state, user: action.payload } case ADD_POST: return { ...state, user: state.user, text: action.payload } case ADD_COMMENT: return { ...state, user: action.payload.user, text: action.payload.text } default: return state; } } actions / PageActions:
import { ADD_POST, ADD_COMMENT } from '../constants/Page' export function addPost(text) { return (dispatch) => { dispatch({ type: ADD_POST, payload: text }) } }