zjffun blog

TypeScript JSX Generics

更新于 写于 typescriptjsx

We can set the type of generic after the component name. Example:

jsx
function Form() {
  // ...

  return (
    <Select<string>
      options={targets}
      value={target}
      onChange={setTarget}
    />
  );
}

See: Passing Generics to JSX Elements in TypeScript — Marius Schulz