1. In most scenarios, the state value changes, and it is hoped that the page will be updated and rendered immediately, so how to do it?
Answer: 1) When setting the state value, return it through a function
2) Realize caching through useRef
const filepath_=useRef<any>()
filepath_.current=data
//这种方式比setState快
console.log("文件夹路径",filepath_);
2. In some scenarios, it is desirable to delay obtaining the status value A. For example, if there is an API whose response is slow to render, the execution of the API may cause the API to return no value if the status value is judged too early (for example, there are too many openlayers map elements, rendering Too slow, slower than getting the state value).
Solution: 1) Set the timer (not recommended)
2) Set the status value in nextTick, and call the function of logic judgment execution in nextTick.
3) Then call the logic judgment execution function in an asynchronous function (backend interface function).