Dice Roller
React.js
medium
20 mins
Create a Dice Roller Component that simulates rolling a dice when a button is clicked. The dice should display a random number between 1 and 6.
Requirements
- The component should have a button labeled "Roll Dice".
- Clicking the button should generate a random number between 1 and 6.
- The rolled number should be displayed on the screen with text ="🎲 diceValue".
- If the Roll Dice button is not clicked , then show a message "Click to roll!"
- The UI should include a dice-like representation (optional).
Constraints & Edge Cases
- Constraint 1: The rolled number should always be between 1 and 6.
- Constraint 2: Ensure the result updates correctly on every button click.
- Edge Case 1: Handle cases where the button is clicked multiple times quickly.
- Edge Case 2: Ensure UI updates correctly when the dice is rolled.
Reference UI

Preview what you need to build
Solve Similar questions 🔥
Want to upskill? Explore our courses!
Namaste DSA
Master DSA from scratch with numerous problems, and expert guidance.
Namaste React
Wanna dive deep into React and become Frontend Expert? Learn with me now!
Namaste Frontend System Design
The most comprehensive and detailed course for frontend system design.
Namaste Node.js
Wanna dive deep into Node.js? Enroll into `Namaste Node.js` now!
