Showing
1 changed file
with
5 additions
and
13 deletions
1 | -import React, { useEffect } from "react"; | 1 | +import React from "react"; |
2 | -import { useMutation, useQuery, useSubscription } from "@apollo/react-hooks"; | 2 | +import { useMutation, useQuery } from "@apollo/react-hooks"; |
3 | import ChatPresenter from "./ChatPresenter"; | 3 | import ChatPresenter from "./ChatPresenter"; |
4 | import { withRouter } from "react-router-dom"; | 4 | import { withRouter } from "react-router-dom"; |
5 | import { | 5 | import { |
... | @@ -15,9 +15,6 @@ export default withRouter(({ location }) => { | ... | @@ -15,9 +15,6 @@ export default withRouter(({ location }) => { |
15 | const { pathname } = location; | 15 | const { pathname } = location; |
16 | const roomName = pathname.slice(1, pathname.length); | 16 | const roomName = pathname.slice(1, pathname.length); |
17 | const [createMsg] = useMutation(CREATE_MESSAGE); | 17 | const [createMsg] = useMutation(CREATE_MESSAGE); |
18 | - const { data: subMessage } = useSubscription(SUBSCRIPTION_MSG); | ||
19 | - | ||
20 | - console.log("subMessage : ", subMessage); | ||
21 | 18 | ||
22 | const message = useInput(""); | 19 | const message = useInput(""); |
23 | 20 | ||
... | @@ -46,15 +43,12 @@ export default withRouter(({ location }) => { | ... | @@ -46,15 +43,12 @@ export default withRouter(({ location }) => { |
46 | messageArray = messageList; | 43 | messageArray = messageList; |
47 | } | 44 | } |
48 | 45 | ||
49 | - let testObj; | 46 | + let resultObj = subscribeToMore({ |
50 | - testObj = subscribeToMore({ | 47 | + document: SUBSCRIPTION_MSG, |
51 | - document: subMessage, | ||
52 | updateQuery: (prev, { subscriptionData }) => { | 48 | updateQuery: (prev, { subscriptionData }) => { |
53 | - console.log("prev : ", prev); | 49 | + if (!subscriptionData.data) return prev; |
54 | - console.log("subscriptionData : ", subscriptionData); | ||
55 | }, | 50 | }, |
56 | }); | 51 | }); |
57 | - console.log(testObj); | ||
58 | 52 | ||
59 | const onSubmit = async (e) => { | 53 | const onSubmit = async (e) => { |
60 | e.preventDefault(); | 54 | e.preventDefault(); |
... | @@ -75,8 +69,6 @@ export default withRouter(({ location }) => { | ... | @@ -75,8 +69,6 @@ export default withRouter(({ location }) => { |
75 | } | 69 | } |
76 | }; | 70 | }; |
77 | 71 | ||
78 | - useEffect(() => {}); | ||
79 | - | ||
80 | return ( | 72 | return ( |
81 | <ChatPresenter | 73 | <ChatPresenter |
82 | location={location} | 74 | location={location} | ... | ... |
-
Please register or login to post a comment