There is no problem if you do it for not very long, but if it becomes hotter or it is very cold in the room I recommend you to first charge your device.
the battery is designed to be charged and drained, it also has a limited time to work (~3-5 years) if the battery drains too quick it might be because it is already too old or it was often used while being hot. Therefore if you feel that your device becomes hot and you continue to use it your battery might loose some of it’s capacity forever.
But it is safe to use it while charging and won’t lose capacity.
Wish you all the best
Nick Inge