botframework-webchat-component
Version:
React component of botframework-webchat
18 lines (14 loc) • 422 B
text/typescript
import { useRef } from 'react';
/**
* Returns `true` if the `value` has changed, otherwise, `false`.
*
* Note: on initial call, this will return `true`.
*
* @param {T} value - The `value` to detect for changes.
*/
export default function useChanged<T>(value: T): boolean {
const prevValueRef = useRef(value);
const changed = value !== prevValueRef.current;
prevValueRef.current = value;
return changed;
}