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 React, { useState } from "react";
|
||||||
import ChatWrapper from "./Chat/ChatWrapper";
|
import Chat from "./Chat/Chat";
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
import { Message } from "./Chat/types";
|
import { Message } from "./Chat/types";
|
||||||
import { MessageContainer } from "./Chat/MessageContainer";
|
import { MessageContainer } from "./Chat/MessageContainer";
|
||||||
|
@ -21,7 +21,7 @@ const App = (): React.ReactElement => {
|
||||||
return <MessageContainer {...message} />;
|
return <MessageContainer {...message} />;
|
||||||
})}
|
})}
|
||||||
{
|
{
|
||||||
<ChatWrapper
|
<Chat
|
||||||
user={username as string}
|
user={username as string}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ const endpoints = {
|
||||||
subscription: "/sub/chat",
|
subscription: "/sub/chat",
|
||||||
history: "/api/v1/msg/",
|
history: "/api/v1/msg/",
|
||||||
};
|
};
|
||||||
const ChatWrapper = ({ user }: { user: string }): React.ReactElement => {
|
const Chat = ({ user }: { user: string }): React.ReactElement => {
|
||||||
const [messages, setMessages] = useState<ReactElement[]>([]);
|
const [messages, setMessages] = useState<ReactElement[]>([]);
|
||||||
let stompClientRef = useRef(
|
let stompClientRef = useRef(
|
||||||
new Client({
|
new Client({
|
||||||
|
@ -117,4 +117,4 @@ const ChatWrapper = ({ user }: { user: string }): React.ReactElement => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default ChatWrapper;
|
export default Chat;
|
|
@ -1,5 +1,5 @@
|
||||||
import { Client } from "@stomp/stompjs";
|
import { Client } from "@stomp/stompjs";
|
||||||
import { Message, MessageType } from "./types";
|
import { Message, MessageType } from "../Chat/types";
|
||||||
const domain = window.location.hostname
|
const domain = window.location.hostname
|
||||||
const port = "8080"
|
const port = "8080"
|
||||||
const connectionAddress = `ws://${domain}:${port}/ws`
|
const connectionAddress = `ws://${domain}:${port}/ws`
|
Loading…
Add table
Add a link
Reference in a new issue