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

2

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?

Sanskrit answered 1/3, 2017 at 21:57 Comment(3)
Hi zinc,. Is there by any chance reselector has the previous state?Sanskrit
Post your code - it will give those trying to help you something to work with.Bewick
Could you show your reducer code? It should return a full new state object every timeFruma
S
2

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"
  }
]
Sanskrit answered 30/10, 2019 at 4:11 Comment(1)
Tks a lot @Sanskrit this was our problem and we to know that object of object things made us realize the problem indeed.Harim
J
-1

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

Jedjedd answered 1/3, 2017 at 22:23 Comment(1)
Thanks for the response. Redux store updated perfectly, I can see that in the mapstatetoprops, which is before I'm calling the selector.Sanskrit

© 2022 - 2025 — McMap. All rights reserved.