In a rainbow, the white light is split into its components. The raindrops behave somewhat like prisms, dispersing the white light into its component colours. These are then internally reflected if the sunlight hits the water drops at proper angle and emerge from the other end.