diff options
author | Vitaly Takmazov | 2019-04-17 17:47:25 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:54 +0300 |
commit | 23efa297c657f18caaf0d68e407fd0d9c7a00256 (patch) | |
tree | 31289ade7f0409cb68043fae0fa13e71c880cc13 /vnext/src/components/Chat.js | |
parent | 423da5baf0aeac7acffc83328a7c3731c2997b98 (diff) |
Fix deps
Diffstat (limited to 'vnext/src/components/Chat.js')
-rw-r--r-- | vnext/src/components/Chat.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/vnext/src/components/Chat.js b/vnext/src/components/Chat.js index 8c1e2311..a1254a10 100644 --- a/vnext/src/components/Chat.js +++ b/vnext/src/components/Chat.js @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState, useCallback } from 'react'; import PropTypes from 'prop-types'; import ReactRouterPropTypes from 'react-router-prop-types'; import { UserType } from './Types'; @@ -25,9 +25,9 @@ export default function Chat(props) { props.connection.removeEventListener('msg', onMessage); } }; - }, [props.connection.readyState]); + }, [props.connection, onMessage, loadChat, props.match.params.user]); - let loadChat = (uname) => { + let loadChat = useCallback((uname) => { const { hash } = props.visitor; setChats([]); if (hash && uname) { @@ -36,16 +36,16 @@ export default function Chat(props) { setChats(response.data); }); } - }; + }, [props.visitor]); - let onMessage = (json) => { + let onMessage = useCallback((json) => { const msg = JSON.parse(json.data); if (msg.user.uname === props.match.params.user) { setChats((oldChat) => { return [msg, ...oldChat]; }); } - }; + }, [props.match.params.user]); let onSend = (template) => { pm(template.to.uname, template.body) |