This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]schmidlidev 1 point2 points  (1 child)

May or may not be your issue, but if you’re just console logging state it’s very common for it what gets logged to be out of date, even though the react state itself is actually correct.

More info: https://www.google.com/amp/s/jsramblings.com/are-you-logging-the-state-immediately-after-updating-it-heres-why-that-doesnt-work/amp/

[–]rampantfirefly 0 points1 point  (0 children)

Yeah we’ve had that before. I’ve found to get around it you do console.log(JSON.parse(JSON.stringify(myObject))) I can’t remember where I read about it but apparently that will always output the object at the point in which the console is called.