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 IntegerToStringConverter() { const [integerList, setIntegerList] = useState([1, 2, 3, 4, 5]); const [stringList, setStringList] = useState([]); useEffect(() => { // Convert the list of integers to a list of strings using toString const convertedList = integerList.map((integer) => integer.toString()); // Update the state with the converted list setStringList(convertedList); }, [integerList]); console.log(stringList) return ( <div className='container'> <h2>React js convert List of Integer to List of String</h2> <p>List of Integers: {integerList.join(', ')}</p> <p>List of Strings: {stringList.join(', ')}</p> </div> ); } ReactDOM.render(<IntegerToStringConverter />, document.getElementById("app")); </script> <style> .container { width: 600px; margin: 0 auto; box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px, rgba(0, 0, 0, 0.06) 0px 2px 4px -1px; padding: 20px; } </style> </body> </html>