<!DOCTYPE html> <html> <head> <title>Chatbot</title> </head> <body> <div class="js-container"></div> <script src="https://unpkg.com/supersimpledev/react.js"></script> <script src="https://unpkg.com/supersimpledev/react-dom.js"></script> <script src="https://unpkg.com/supersimpledev/babel.js"></script> <script type="text/babel"> function ChatInput(){ return ( /* <div> <input /> <button>Send</button> </div> */ <> {/* using fragment to remove extra div elements */} <input placeholder="Send a message to chatbot" size="30"/> <button>Send</button> </> ); } function ChatMessage({message, sender}){ return ( <div> {/* use div element to put the ChatMessage on a new line */} {sender === 'robot' && <img src="robot.jpeg" width= "50"/>} {message} {sender === 'user' && <img src="human.jpeg" width= "50"/>} </div> ) } function ChatMessages() { const chatMessages = [{ message: 'hello chatbot', sender: 'user', id : 'id1' }, { message: 'Hello! How can I help you?', sender: 'robot', id : 'id2' }, { message: 'Can you get me todays date?', sender: 'user', id : 'id3' }, { message: 'Today is September 26', sender: 'robot', id : 'id4' } ] ; // function sendMessage() { // console.log('send message'); // } function sendMessage() { chatMessages.push({ message : 'test', sender : 'user', id : crypto.randomUUID() }); } console.log(chatMessages); return ( <> <button onClick={sendMessage}>Send Message </button> {chatMessages.map((chatMessage) => { return ( <ChatMessage message={chatMessage.message} sender={chatMessage.sender} key={chatMessage.id} /> ); })} </>) } function App (){ return (<> <ChatInput /> <ChatMessages /> </>); } //const app = ( App ); const container = document.querySelector('.js-container'); ReactDOM.createRoot(container).render(<App />); </script> </body> </html>
Navigation Bar
- Oracle Developer
- Date Functions
- Queries
- PL/SQL
- Oracle XML DB
- Oracle XML DB: An Example
- To Store and Select XML Data
- XMLDB : Examples of using getClobVal, getStringVal and getNumberVal
- XMLDB: Convert xml file into equivalent relational dataset
- XMLDB: XML to HTML with XSL stylesheet
- XMLDB : DBUriType
- XMLDB : XML Functions continued ...
- XMLElement, XMLAttributes, XMLAgg, XMLForest - Examples
- JSON in Oracle
- Working with JSONs in Oracle
- PL/SQL Object Types and Methods for JSON
- Oracle JSON : Select Level 1 and Level 2 data
- A JSON generator using SQL and PLSQL
- XML to JSON and JSON to XML
- Parsing a JSON object with Oracle PLSQL
- Parsing and updating a JSON object using PLSQL
- A generic JSON parser with update using Oracle PL/SQL
- A generic multi level JSON object parse and update script using PLSQL
- A generic JSON parser and JSON generator using a config table
- A generic JSON generator using a config table
- Common Oracle Errors
- Exception Handling
- Archiving
- Reclaim tablespace size after a large table delete
- Data Archiving in Oracle
- Archiving a generic solution - Part 1
- Archiving a generic solution - Part 2
- Archiving a generic solution - Part 3
- Archiving a generic solution - Part 4
- Archiving a generic solution - Part 5
- Archiving a generic solution - Part 6 - Deploy and Test
- Archiving - Case Study for optimizing disk space utilization with archiving
- Archiving : Changes for data replication
- Archiving : A case study for data replication
- Data Replication : Using Change Notification and DBMS_SCHEDULER as a LISTENER
- Oracle DBA
- Knowledge Base
- Linux
- Oracle Dewdrops
- Newsletters
- Java
Thursday, October 1, 2026
React - Chatbot Event Handler
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment