Skip to content

Instantly share code, notes, and snippets.

View huykon's full-sized avatar
✌️
Be you wanna be

Huy Kon huykon

✌️
Be you wanna be
  • freelancer
  • Việt Nam
View GitHub Profile
@huykon
huykon / usePrevious.js
Last active April 6, 2021 01:56
Custom hook store previous state
import { useEffect, useRef } from 'react';
export function usePrevious(value) {
const ref = useRef();
useEffect(() => {
ref.current = value;
});
return ref.current;
}