screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <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 [array] = useState([1, 2, 3, 3, 4, 5, 5, "a", "b", "c", "c"]); const [set, setSet] = useState(new Set()); useEffect(() => { const convertedSet = new Set(array); setSet(convertedSet); }, [array]); return ( <div className="container"> <h3>React Js Convert Array to Set</h3> <h2>Original Array:</h2> <p>{JSON.stringify(array)}</p> <h2>Converted Set:</h2> <p>{JSON.stringify(Array.from(set))}</p> </div> ); }; ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { text-align: center; margin-top: 100px; } </style> </body> </html>