I've been in the tech industry for 45 years. Layoffs happen regularly. Well, not
regularly, what it is is a chaotic system. There will be good times and bad times. The best way to deal with it is to immediately save, at a minimum, 6 months of runway. Preferably a year.
When you're in between jobs, work on:
1. improving your job skills
2. network
3. build your resume by contributing to open source
4. start your own business