sdy

create ChatContainer.js

1 +import React from "react";
2 +import { useSubscription, useMutation } from "@apollo/react-hooks";
3 +import ChatPresenter from "./ChatPresenter";
4 +import { withRouter } from "react-router-dom";
5 +import { NEW_MESSAGE, SUBSCRIPTION_MSG } from "./ChatQueries";
6 +import useInput from "../../Hooks/useInput";
7 +
8 +export default withRouter(({ location }) => {
9 + const [createMsg] = useMutation(NEW_MESSAGE);
10 + const {
11 + data: { subMessage },
12 + } = useSubscription(SUBSCRIPTION_MSG);
13 +
14 + const message = useInput("");
15 +
16 + const onSubmit = async (e) => {
17 + e.preventDefault();
18 + };
19 +
20 + return (
21 + <ChatPresenter location={location} message={message} onSubmit={onSubmit} />
22 + );
23 +});