I had excellent experience with folding rubber lenshood on Nikkor 50’s for more than 40 years. Recently converted to metal screw on hoods. Same good experience but makes the camera a couple of inches deeper.
No big deal. No experience with generic but don’t know why they wouldn’t work as well as a Nikon unless it’s a real piece of junk. Lately, though, the knock-offs have been impressively high quality.
I’ve also used the Nikon snap-on hoods. They sometpop off when bumped, but less so when snapped on and gently tighter by screwing it on until it stops. Any tighter than that and it will pop off.