8

Now I'm working in react-redux. I'm trying to get questions from state one-by-one. Generated unique ID to store the questions in the state, after user submits,answer also store with the question.

Uniqueid: { Question: question goes here, Answer: '' }

React component to render the question. I used selector in the mapstatetoprops to select question from state.

Now is my question: Selector triggers first time perfectly. After user submits the question answer also updated. After that, selector not triggering, I can't find why?

satheesh
  • 403
  • 5
  • 15

2 Answers2

1

I'm still seeing activity in this page. Redux selector can't recognize changes in the object of object or array of objects. See the below example.

{firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"}

Selector can recognize the changes in the above object.

{
  firstName:"John", 
  lastName:"Doe", 
  featuer: { 
    age:50, 
    eyeColor:"blue" 
  }
}

If you made changes in the featuer object selectore won't recognize the changes. Same thing goes for the below array object too.

[
  {
    firstName:"John", 
    lastName:"Doe",
    age:50, 
    eyeColor:"blue"
  },
  {
    firstName:"John", 
    lastName:"Doe",
    age:50, 
    eyeColor:"blue"
  }
]
satheesh
  • 403
  • 5
  • 15
  • Tks a lot @satheesh this was our problem and we to know that object of object things made us realize the problem indeed. – Luan Cardoso Dec 02 '19 at 20:16
-1

It depends on how are you updating your redux store. please make sure you are doing it right using redux troubleshooting.

alireza
  • 518
  • 5
  • 15
  • Thanks for the response. Redux store updated perfectly, I can see that in the mapstatetoprops, which is before I'm calling the selector. – satheesh Mar 01 '17 at 22:33