Skip to content

Instantly share code, notes, and snippets.

@drewwyatt
Last active May 19, 2019 04:02
Show Gist options
  • Save drewwyatt/b905f397095f5c27554a11620316d2bc to your computer and use it in GitHub Desktop.
Save drewwyatt/b905f397095f5c27554a11620316d2bc to your computer and use it in GitHub Desktop.
onClick={wat} snippet
import React, { DetailedHTMLProps, FC, HTMLAttributes } from 'react';
import { useNativeEvent } from './useNativeEvent';
type ButtonProps = DetailedHTMLProps<HTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
type Props =
& ButtonProps
& { onClick: EventListener }; // make onClick required
export const NativeEventButton: FC<Props> = ({ onClick, ...rest }) => {
const ref = useNativeEvent('click', onClick)
return <button {...rest} ref={ref} />
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment