I've never specialized in one field.
I've worked with frontend, backend, DevOps, and a bit of QA. I now develop tools in my company to make other developers more productive.
Creating tools is the most fun I had with software engineering. But it wouldn't have been possible if I specialized in one field such as frontend or backend.
But it's bigger than that, I've realized that I'm very lucky to not have put myself in any box and simply followed my curiosity.
I haven't fallen into the trap called "specialization".
The Specialization Trap
The specialization trap refers to putting yourself in a box. The box can be big, like frontend developer, or small, like react developer.
No matter how big or small the box is, it is still a box. Now, you might ask, how is this bad?
Reason #1: You can't predict the future.
The technology of today is the legacy of tomorrow. If you put all your baskets into one technology, then that might bite you in the ass later on.
For example, a few months ago I saw that people were complaining about choosing to specialize in Flutter due to the lack of jobs they have now. The same thing can be said about "react developers" when react goes obsolete.
Some can be lucky and choose a specialization that is in high demand with low supply, such as Cobol developers. But that is short-lived because companies will try in any possible way to migrate it to a more modern language.
Reason #2: It limits your problem-solving skills.
If you only ever study one field of development, then all your perspectives will be from that one field.
For example, you specialize in React and when you try to migrate over to some other framework, you'll try to solve problems the React way which isn't always the best.
Reason #3: It's boring and limits growth.
If something is boring then it will suck the life out of you. I'm not saying to always be doing something exciting but if you keep doing the same stuff for 5 years then you've essentially wasted 4 of those years.
I also believe this is when people experience burnout. In my humble opinion, burnout doesn't happen from too much work but from too much soul-crushing work.
So, what should I do instead?
Learn the fundamentals and try to specialize in 2-3 fields.
Learning the fundamentals first will enable you to learn other skills much faster because everything is built upon the fundamentals.
Then, I would suggest to specialize in 2-3 fields. Three might be a bit far-fetched but two is definitely doable.
Don't think too much about it, just follow your curiosity.