M
M
mr jeery2018-02-15 06:30:57
React
mr jeery, 2018-02-15 06:30:57

Why does the store change and the page doesn't render?

I look through devTools, everything is filled in the store as it should, but the page does not change, only if you update the component yourself. Am I violating redux's immutability philosophy? How to do it right?

const INITIAL_STATE = {
  cards: [
    entries: [
    ]
  ]
};


const addEntry = (state, action) => {
  let newState = state;
  let cardIndex = newState.cards.findIndex((card)=>card.id == action.id);

  newState.cards[cardIndex].entries.push({ entry: '', idEntry: Math.random().toString(36).substring(7) })

  return {
    cards: newState.cards
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question