diff --git a/src/layout/components/Button.tsx b/src/layout/components/Button.tsx index f8fc6e8..c5e3529 100644 --- a/src/layout/components/Button.tsx +++ b/src/layout/components/Button.tsx @@ -1,13 +1,10 @@ -import React, {FunctionComponent} from "react"; +import React, {ButtonHTMLAttributes, DetailedHTMLProps, FunctionComponent} from "react"; -interface Props { - className?: string - onClick?: () => void - children?: React.ReactNode -} +export const GHButton: FunctionComponent, HTMLButtonElement>> = (props) => { + + const {className, ...rest} = props; -export const GHButton: FunctionComponent = ({className, onClick, children}) => { return ( - {children} + ); } \ No newline at end of file diff --git a/src/layout/pages/Room.tsx b/src/layout/pages/Room.tsx index 7ccb713..920434c 100644 --- a/src/layout/pages/Room.tsx +++ b/src/layout/pages/Room.tsx @@ -1,5 +1,5 @@ import useWebSocket from "react-use-websocket"; -import React from "react"; +import React, {FormEvent} from "react"; import {useNavigate, useParams} from "react-router"; import {GHButton} from "../components/Button"; import useTitle from "../../utils/hooks/TitleHook"; @@ -91,11 +91,13 @@ const Room = () => { }); } - const handleChat = (message: string) => { + const handleChat = (e: FormEvent) => { + e.preventDefault(); handleSend({ Type: "CHAT", - Payload: message + Payload: chatInput }); + setChatInput(''); } return ( @@ -103,8 +105,10 @@ const Room = () => {

Room {roomId}

Leave Room - setChatInput(e.target.value)} /> - +
+ setChatInput(e.target.value)} /> + Send +
    {chatMessages.map((message, index) => (
  • {message.PlayerName}: {message.Message}