diff --git a/sports-matcher/src/ChatWindow.js b/sports-matcher/src/ChatWindow.js index 2db5275..036ad55 100644 --- a/sports-matcher/src/ChatWindow.js +++ b/sports-matcher/src/ChatWindow.js @@ -4,6 +4,7 @@ import React from 'react'; import './chats.css' import Chat from './Chat' import Contact from './Contact' +import { useState } from "react"; class ChatWindow extends React.Component { render() { @@ -11,15 +12,14 @@ class ChatWindow extends React.Component {
+
) } - test() { - alert("test") - } } class UserList extends React.Component { + render() { return (
@@ -35,26 +35,10 @@ class MessageList extends React.Component { render() { return (
-
-
- Got time for tennis this week, Raiden? -
-
-
-
- Foolish question. If I do not even have free time, How am I to pursue eternity and fulfill my promise to the people of Inazuma? -
-
-
-
- Aiight, see you at 4 -
-
-
-
- As you wish. -
-
+ + + +
) } @@ -69,9 +53,61 @@ class MessageList extends React.Component { // ) // } // } -class ChatInput extends React.Component { +const ChatInput = () => { + const [message, setMessage] = useState( '' ); + + // const onKeyPress = (e) => { + // // if(e.key === 'Enter'){ + // // e.preventDefault(); // Ensure it is only this code that runs + // // setMessage("") + // // } + // } + + const onKeyDown = (e) => { + const keyCode = e.which || e.keyCode; + + // 13 represents the Enter key + if (keyCode === 13 && !e.shiftKey) { + e.preventDefault(); + setMessage("") + } + } + + return ( + // onKeyPress={(e) => onKeyPress(e)} +
+