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> <title>Date Difference Calculator</title> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState, useEffect } = React; function App() { const [inputString, setInputString] = useState("key1:value1,key2:value2,key3:value3"); const keyValuePairs = inputString.split(",").map(pair => pair.split(":")); const keyValueObject = Object.fromEntries(keyValuePairs); return ( <div className='container'> <h2 className='title'>React Js Convert String into Key-Value Object:</h2> <p className='text'>String: {inputString}</p> <pre className='code'>{JSON.stringify(keyValueObject, null, 2)}</pre> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f5f5f5; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); } /* Title styles */ .title { font-size: 24px; color: #333; margin-bottom: 10px; } /* Text styles */ .text { font-size: 18px; color: #555; } /* Code block styles */ .code { font-family: 'Courier New', monospace; font-size: 16px; background-color: #f9f9f9; padding: 10px; border: 1px solid #ddd; border-radius: 5px; overflow-x: auto; white-space: pre-wrap; } </style> </body> </html>