mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-25 23:05:23 +00:00
useEvent
This commit is contained in:
@@ -4,10 +4,9 @@
|
||||
|
||||
import {
|
||||
useRef,
|
||||
useInsertionEffect,
|
||||
useCallback,
|
||||
useState,
|
||||
useEffect,
|
||||
experimental_useEvent as useEvent,
|
||||
Fragment,
|
||||
} from 'react';
|
||||
import cn from 'classnames';
|
||||
@@ -22,19 +21,6 @@ import {DownloadButton} from './DownloadButton';
|
||||
import {IconChevron} from '../../Icon/IconChevron';
|
||||
import {Listbox} from '@headlessui/react';
|
||||
|
||||
// TODO: Replace with real useEvent.
|
||||
export function useEvent(fn: any): any {
|
||||
const ref = useRef(null);
|
||||
useInsertionEffect(() => {
|
||||
ref.current = fn;
|
||||
}, [fn]);
|
||||
return useCallback((...args: any) => {
|
||||
const f = ref.current!;
|
||||
// @ts-ignore
|
||||
return f(...args);
|
||||
}, []);
|
||||
}
|
||||
|
||||
const getFileName = (filePath: string): string => {
|
||||
const lastIndexOfSlash = filePath.lastIndexOf('/');
|
||||
return filePath.slice(lastIndexOfSlash + 1);
|
||||
|
||||
Reference in New Issue
Block a user