Actually they did have sunscreen! And other sun protection.
The oldest use of the umbrella we know of was for Ancient Egyptians to keep out of the sun: https://en.m.wikipedia.org/wiki/Umbrella
The Himbaa people use otjize, a combination of clay, herbs, and other ingredients, to protect themselves from the sun and keep clean: https://en.m.wikipedia.org/wiki/Otjize
We have also used a variety of sunscreen and sun protection throughout history. Check out the history section of this page:
https://en.m.wikipedia.org/wiki/Sunscreen
This doesn't even count the various clothing traditions for sun protection.

















