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, useEffect } = React; function App() { const [currentPathname, setCurrentPathname] = useState(window.location.pathname); return ( <div className='container'> <h3 className='title'>React Js Get Current Pathname of URL</h3> <p className='description'>Current Pathname: {currentPathname}</p> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { font-family: Arial, sans-serif; padding: 20px; border-radius: 5px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); max-width: 600px; margin: 0 auto; text-align: center; } /* Styles for the title */ .title { font-size: 24px; color: #333; margin: 10px 0; } /* Styles for the description */ .description { font-size: 18px; color: #666; } </style> </body> </html>