screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useEffect, useState } = React; const App = () => { const [currentYear, setCurrentYear] = useState(""); useEffect(() => { const currentYear = new Date().getFullYear(); setCurrentYear(currentYear); }, []); return ( <div className="container"> <h1>React Get Current Year</h1> <p>Current year: {currentYear}</p> </div> ); }; ReactDOM.render(<App />, document.getElementById("app")); </script> </body> </html>