Taiwan though is different. China is not a strong naval power, its strength traditionally relying on its overwhelmingly immense land army. Amphibious invasions are among the most difficult operations in warfare, and Taiwan's geography limits potential invasions to only a few easily defendable points. China is building up its naval capabilities, but getting to the point that seizing Taiwan is even feasible will still take years - years that they don't have. This is to say nothing of the inevitable coalition that would join Taiwan in resisting such an invasion. Without experience in such invasions, China would be likely to suffer tremendous losses for trivial gains, at least at first. This would make the CCP appear incompetent and further reduce their military capabilities at exactly the same time that they would be most at risk of internal strife, which no doubt foreign powers would be throwing their full weight behind.
No, it makes more sense that China's current posturing is saber rattling meant to stir nationalist sentiment in its own population. It's the same reason for its recent clashing with India and its remarkable recent diplomatic hostility. The last thing it wants or needs is new territory full of independence minded dissidents, but creating external enemies is a classic and often effective play for regimes on rocky ground.
While it's always possible that some hawkish firebrand comes to power or there is some major miscommunication that leads to hostility, the CCP and Xi especially have a long track record of pursuing stability above all else, which has honestly been the Chinese goto play for thousands of years. An invasion of Taiwan would be in direct opposition to that goal, and could only end very badly for the CCP and Xi. Perhaps if China survives its demographic crisis it will emerge as a premiere power that can seriously consider such military expeditions, but it'll be dealing with that problem for a generation.