-React merges multiple consecutive setstates. If you want to use the result of the last setState immediately for the next setState, you can make the setState accept a function instead of an object. This function takes the first parameter as the last state and the second parameter as props for the update being applied at this timeCopy the code