Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redux Selector not triggering when I'm calling it from mapstatetoprops

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?

like image 365
satheesh Avatar asked Mar 01 '17 21:03

satheesh


1 Answers

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"
  }
]
like image 89
satheesh Avatar answered Sep 16 '22 13:09

satheesh