Skip to content

Instantly share code, notes, and snippets.

View Freak613's full-sized avatar

Pavel Martynov Freak613

  • San Francisco, CA
View GitHub Profile
// Fork of https://github.com/shiningjason/react-enhanced-reducer-hook/blob/master/index.js
const useHandler = fn => {
const ref = useRef({
fn,
handler: (...args) => ref.current.fn(...args)
});
ref.current.fn = fn;
return ref.current.handler;
};