Skip to content

Instantly share code, notes, and snippets.

View gfox1984's full-sized avatar

Guillaume RENARD gfox1984

View GitHub Profile
import { useRef, useInsertionEffect, useCallback } from 'react';
// The useEvent API has not yet been added to React,
// so this is a temporary shim to make this sandbox work.
// You're not expected to write code like this yourself.
export function useEvent(fn) {
const ref = useRef(null);
useInsertionEffect(() => {
ref.current = fn;