<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<script type="text/babel">
// Add the import statement for useState hook
const { useState } = React;
// Define the App component
const [randomNumber, setRandomNumber] = useState(null);
const generateRandomNumber = () => {
const randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
setRandomNumber(randomNum);
<div className="container">
<h3>React Js Generate Random Number Between 1- 10</h3>
<button onClick={generateRandomNumber}>
{randomNumber !== null && <p>Random Number: {randomNumber}</p>}
ReactDOM.render(<App />, document.getElementById("app"));
font-family: Arial, sans-serif;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
/* Styles for the button */
background-color: #4caf50;
transition: background-color 0.3s;
.container button:hover {
background-color: #45a049;
/* Styles for the generated number */