mirror of
https://github.com/usebruno/bruno.git
synced 2025-07-14 19:25:31 +02:00
14 lines
354 B
JavaScript
14 lines
354 B
JavaScript
import { useRef, useEffect } from 'react';
|
|
|
|
function usePrevious(value) {
|
|
const ref = useRef();
|
|
|
|
useEffect(() => {
|
|
ref.current = value; //assign the value of ref to the argument
|
|
}, [value]); //this code will run when the value of 'value' changes
|
|
|
|
return ref.current; //in the end, return the current ref value.
|
|
}
|
|
|
|
export default usePrevious;
|