I've played a Rogue character in a few campaigns. At level 5, Rogues gain the Uncanny Dodge feature, described as follows:
Starting at 5th level, when an attacker that you can see hits you with an attack, you can use your reaction to halve the attack’s damage against you.
In practice, this has never been an issue, as my DMs have always allowed me to choose whether to use Uncanny Dodge after damage has been rolled... But I recently came across someone asking whether it had to be done before or after damage was rolled, and I realized I wasn't sure.
So obviously, Uncanny Dodge can only be used after a successful attack roll by the enemy, but according to the rules, does Uncanny Dodge have to be decided upon before or after damage is rolled? (Both RAW and RAI answers are welcome as long as they are properly supported.)