You’re free to do what you want. I just find a lot of the entire FOSS process kind of exploitative and why I have become disillusioned with it.
ETA:
To be clear, I have a fair active GitHub and I still post stuff on there fairly often, and even a few non-trivial things. I just have stopped compulsively putting every line of code I write in public repositories.
But lots of programmers don't get properly compensated. Some by choice, some by external factors.
I'm saying that's a reality. How you feel about other programmers and the choices they make for themselves is up to you.
Clearly there's no obligation to post anything yo public repositories, send the vast majority of programmers never do.
I am merely explaining why I choose not to partake in FOSS when I think it’s exploitive. People are free to disagree, or not care, and that’s obviously fine, but I choose to not directly contribute to it.
You may decide its worth people using it, reading it, learning from it, exploiting it, or you may not. It's your choice.
Of course your work may be used outside of the license terms. That's pretty much impossible to enforce. That's true for most-all software, commercial or open or free. If that's your main objection to writing code then I recommend a different career. All good code is pirated. That's just how it is.