Rename custom hook
This commit is contained in:
parent
1143cb87c7
commit
65b59a6062
@ -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(() => {
|
||||
|
@ -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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user