screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script> <script src="https://unpkg.com/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> </head> <body> <div id="app"></div> <script type="text/babel"> function isObjectEmpty(obj) { return Object.keys(obj).length === 0; } function App() { const myObject = {}; // An empty object const isEmpty = isObjectEmpty(myObject); return ( <div className='container'> <h3>React Js Check Object is Empty</h3> {isEmpty ? ( <p className='empty-message'>The object is empty.</p> ) : ( <p className='non-empty-message'>The object is not empty.</p> )} </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { max-width: 500px; margin: 0 auto; text-align: center; padding: 20px; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } /* Empty message styles */ .empty-message { font-size: 24px; color: #f44336; /* Red color for empty message */ } /* Non-empty message styles */ .non-empty-message { font-size: 24px; color: #4caf50; /* Green color for non-empty message */ } </style> </body> </html>