screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://unpkg.com/react@17.0.2/umd/react.development.js"></script> <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js"></script> <script src="https://unpkg.com/@babel/standalone@7.14.7/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState } = React; function App() { const [randomNumber, setRandomNumber] = useState(""); function myFunction() { setRandomNumber(Math.random() * 100); } return ( <div id="app"> <h2>React js Math.random() </h2> <p>Generate Random Number between 1-100 in React Js</p> <button onClick={myFunction}>click me</button> <p>Random Number = {randomNumber}</p> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> #app { text-align: center; font-family: Arial, sans-serif; padding: 20px; } h2 { font-size: 24px; font-weight: bold; margin-bottom: 10px; } p { font-size: 18px; margin-bottom: 10px; } button { font-size: 18px; padding: 10px 20px; background-color: #4caf50; color: #fff; border: none; border-radius: 5px; cursor: pointer; } button:hover { background-color: #3e8e41; } p:last-child { font-size: 24px; font-weight: bold; } </style> </body> </html>