A little doubt about reading the official documents of React

There are two areas in the

State and Lifecycle section that I don"t quite understand

1. State Updates are Merged

The merging is shallow, so this.setState ({comments}) leaves this.state.posts intact, but completely replaces this.state.comments.

my understanding is that when this.setState () is called by multiple asynchronous requests, this.setState () will not update the view until the last request is returned, and all the previous this.setState () has done is to merge the this.state object. Is there a problem with this understanding? If there is no problem, how to translate the above quote?

Feb.26,2021

an example illustrates the problem:
this.state = {a: 1, b: 2};
when you execute this.setState ({a: 3}) , it does not affect its b value.
the final result is {a: 3, b: 2}

means to completely replace this attribute of your setState without affecting the values of other attributes. Similar to the Object.assgin () function.


updates the view in one cycle, not after multiple asynchronous requests are returned. this.setState ({comments}) will replace the comments in your state with this new comments, that is, a shallow copy


.

you can compare setState changes to operands. Every time you change the inner value of {a: 2, b: 4} , you don't use obj.an or obj.b to change obj.b = 3.

so can be said that every time setState merges state (before merging, preState () and currentState (current state). And only one or more values in preState and currentState are different.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bdf6bd-52b14.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bdf6bd-52b14.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?