import React, { useContext, useEffect, useRef } from 'react' import "./ChatFooter.css"; import { PaperAirplaneIcon, PhotoIcon, PaperClipIcon, FaceSmileIcon } from "@heroicons/react/24/solid"; import { SocketContext } from '../../contexts/SocketProvider'; function ChatFooter({ currentChatId, }) { // console.log(currentChatId) const socket = useContext(SocketContext); const messageRef = useRef(); const sendMessage = (message) => { if (message.trim() === "") return; const message_bundle = { content:message, receiver_id: currentChatId, type:"text", } if (socket) { socket.emit("send_message", message_bundle); } messageRef.current.value = ""; } const handleEnter = (e) => { if (e.key == "Enter") { sendMessage(messageRef.current.value); } } return ( ) } export default ChatFooter