That is not true - h1b holders can switch jobs and transfer the visa to the new employer
In the past USCIS offered an unofficial grace period of about a month to find another job, but this is unofficial, and considering the current environment where the SC just approved a government request that allows the government to use the fact that you apply for a green card as a negative during your green card application, people should be extremely worried about the transition time.
Further, the USCIS has been ridiculously slow for the past couple of years in approving stuff, and has been holding up requests for trivial reasons, but now specifically, they will be hitting the March time period when new visas take priority and the odds of a transfer approval happening in a reasonable amount of time is really low.
Edit: it looks like there is now a grace period before having to leave the country.