The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

bruno_bravo (10) [Avatar] Offline
#1
Section '3.2.1. Mutable state in React: Component state' says:

"With past versions of React you could pass an object instead of a function as the first argument to setState."

Is it accurate? What I understood was that in React 16 you can't pass and objects to 'setState' function which accordingly to React docs is not true: https://reactjs.org/docs/react-component.html#setstate

Could someone help me to clarify that?

thanks,
mark (60) [Avatar] Offline
#2
hey! good question. For a long time setState just accepted an object to use, but it was confusing to people because even though it looked like a sync. method it was actually "React please schedule this update". So in 16 you can do either but future versions only the callback signature will work. Let me know if that doesn't make sense or if I can help in any other way!