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 [demoArray, setDemoArray] = useState([]); return ( <div class='component'> <h3>React Js Check Element Exist in Array</h3> {demoArray.length === 0 ? ( <p>Array is empty</p> ) : ( demoArray.map((item) => <p key={item}>{item}</p>) )} </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .component { padding: 20px; border: 1px solid #ccc; } h3 { font-size: 24px; margin-bottom: 10px; } p { font-size: 16px; margin-bottom: 5px; } </style> </body> </html>