bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/utils/hooks/index.js
2023-07-19 13:22:50 -03:00

20 lines
393 B
JavaScript

import { useEffect, useRef } from 'react';
/**
* 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;
});
return ref.current;
};
export default {
usePreviousValue,
};