ReactJS
1import React from "react";2
3export function pickFromSyntheticEvent<T extends HTMLElement>() {4return <K extends keyof T>(key: K) =>5<E extends ((t: T[K]) => void)> (fn: E) =>6(e: React.SyntheticEvent<T>) =>{7fn(e.currentTarget[key]);8}9}
10
11export const getValue = pickFromSyntheticEvent<HTMLInputElement>()("value");12export const getChecked = pickFromSyntheticEvent<HTMLInputElement>()("checked");