refactored code. Moved non-tsx bits to /src/handlers/
This commit is contained in:
parent
847ecd9a69
commit
1f696f34c2
3 changed files with 5 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
import React, { useState } from "react";
|
||||
import ChatWrapper from "./Chat/ChatWrapper";
|
||||
import Chat from "./Chat/Chat";
|
||||
import "./App.css";
|
||||
import { Message } from "./Chat/types";
|
||||
import { MessageContainer } from "./Chat/MessageContainer";
|
||||
|
@ -21,7 +21,7 @@ const App = (): React.ReactElement => {
|
|||
return <MessageContainer {...message} />;
|
||||
})}
|
||||
{
|
||||
<ChatWrapper
|
||||
<Chat
|
||||
user={username as string}
|
||||
/>
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ const endpoints = {
|
|||
subscription: "/sub/chat",
|
||||
history: "/api/v1/msg/",
|
||||
};
|
||||
const ChatWrapper = ({ user }: { user: string }): React.ReactElement => {
|
||||
const Chat = ({ user }: { user: string }): React.ReactElement => {
|
||||
const [messages, setMessages] = useState<ReactElement[]>([]);
|
||||
let stompClientRef = useRef(
|
||||
new Client({
|
||||
|
@ -117,4 +117,4 @@ const ChatWrapper = ({ user }: { user: string }): React.ReactElement => {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
export default ChatWrapper;
|
||||
export default Chat;
|
|
@ -1,5 +1,5 @@
|
|||
import { Client } from "@stomp/stompjs";
|
||||
import { Message, MessageType } from "./types";
|
||||
import { Message, MessageType } from "../Chat/types";
|
||||
const domain = window.location.hostname
|
||||
const port = "8080"
|
||||
const connectionAddress = `ws://${domain}:${port}/ws`
|
Loading…
Add table
Add a link
Reference in a new issue