diff --git a/src/Pages/Messaging/Messaging.js b/src/Pages/Messaging/Messaging.js
index dd1d54ff1..6b2cb2f0c 100644
--- a/src/Pages/Messaging/Messaging.js
+++ b/src/Pages/Messaging/Messaging.js
@@ -1,10 +1,12 @@
import React, { useState, useEffect } from 'react';
import { sendMessage, connectToRoom } from '../../APIFunctions/Messaging';
import { useParams, useHistory } from 'react-router-dom/cjs/react-router-dom.min';
+import { useUser } from '../../Components/context/UserContext';
-export default function Messaging(props) {
+export default function Messaging() {
const { id } = useParams();
const history = useHistory();
+ const { user } = useUser();
const [roomIdInput, setRoomIdInput] = useState(id || '');
const [roomIdSubmit, setRoomIdSubmit] = useState(id || 'general');
@@ -33,8 +35,8 @@ export default function Messaging(props) {
Connect
-
-
+
+
);
}
@@ -46,14 +48,13 @@ function MessagingForm(props) {
const { token, id } = props;
-
const handleSubmit = async (event) => {
event.preventDefault();
const status = await sendMessage(id, token, message);
if (status.error) {
- setErrorMessage(status.responseData.response.data || 'An error occurred while sending the message.');
+ setErrorMessage(status.responseData?.response?.data || 'An error occurred while sending the message.');
} else {
setErrorMessage('');
}