Pololu Carrier with Sharp GP2Y0A60SZLF IR distance sensor - mount it with hot glue
Hot glue melts at ~120C. By the time you have put it on the surface and pushed the PCB against it will cooled rapidly. Electric components are build to withstand 125C for short periods. The data sheet says:
Soldering temperature  Tsol  260  °C  5s or less/time up 2 times

I looked at the Electro-optical Characteristics in the datasheet which mentions 50mA. I found the note you mentioned: Please use an electric source with an output current of 400mA or more because LED pulse current is more than 300mA. That energy will not be at the bottom of the PCB as it is the led, sticking out at the top, which even has a plastic housing.

Sticking with 5V and the full 50mA of the chip (on the PCB) the energy is 0.25 watts. The energy will go mostly in the PCB which works as a heat sink. Your glue will not make a noticeable difference.