diff --git a/bigbluebutton-html5/imports/ui/components/chat/alert/component.jsx b/bigbluebutton-html5/imports/ui/components/chat/alert/component.jsx index 5475a14658..ee5704dbf8 100644 --- a/bigbluebutton-html5/imports/ui/components/chat/alert/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/chat/alert/component.jsx @@ -9,7 +9,7 @@ import ChatPushAlert from './push-alert/component'; import { stripTags, unescapeHtml } from '/imports/utils/string-utils'; import Service from '../service'; import Styled from './styles'; -import { usePrevious } from '/imports/ui/components/utils/hooks'; +import { usePreviousValue } from '/imports/ui/components/utils/hooks'; const CHAT_CONFIG = Meteor.settings.public.chat; const PUBLIC_CHAT_CLEAR = CHAT_CONFIG.chat_clear; @@ -76,7 +76,7 @@ const ChatAlert = (props) => { const [unreadMessages, setUnreadMessages] = useState([]); const [lastAlertTimestampByChat, setLastAlertTimestampByChat] = useState({}); const [alertEnabledTimestamp, setAlertEnabledTimestamp] = useState(null); - const prevUnreadMessages = usePrevious(unreadMessages); + const prevUnreadMessages = usePreviousValue(unreadMessages); // audio alerts useEffect(() => { diff --git a/bigbluebutton-html5/imports/ui/components/utils/hooks/index.js b/bigbluebutton-html5/imports/ui/components/utils/hooks/index.js index a0ecffb7f9..5d79cce7ab 100644 --- a/bigbluebutton-html5/imports/ui/components/utils/hooks/index.js +++ b/bigbluebutton-html5/imports/ui/components/utils/hooks/index.js @@ -1,6 +1,12 @@ import { useEffect, useRef } from 'react'; -export const usePrevious = (value) => { +/** + * Custom hook to get previous value. It can be used, + * for example, to get previous props or state. + * @param {*} value + * @returns The previous value. + */ +export const usePreviousValue = (value) => { const ref = useRef(); useEffect(() => { ref.current = value; @@ -9,5 +15,5 @@ export const usePrevious = (value) => { } export default { - usePrevious, + usePreviousValue, };