Here's how I fixed mine. Unfortunately, that entire shelf collapsed (several times). This was my "final" fix. It not only holds the shelf up, but it also holds the clothes bar up also. After I did this, I never had problems again.
My closet is along the entire rear of the camper. It gets the most bounce. Add a couple hundred pounds of clothing on that cloths rod and add "stuff" with weight on the shelf above, and those 4 original screws that were screwed into a styrofoam wall didn't have a chance. The firs time the shelf collapsed was on our maiden voyage. What a mess to deal with. It took 3 different attempts. This is the one that actually worked and has held the test of time.
The middle board is supported by 2 small supports on each side, top and bottom. The boards on the wall are held up with Liquid Nails. The boards are wedged tight. The shelf cannot collapse any more and it's strong now!
__________________
History is not about the past, it's an explanation of the present.
2019 Montana High Country 375FL
2014 Chevy Silverado Duramax, 6.6L Dually