for-ui icon indicating copy to clipboard operation
for-ui copied to clipboard

forwardRefを使っているComponentのrefの型が異なる

Open Qs-F opened this issue 2 years ago • 1 comments

Props型をexportしているだけだとrefがMUI由来のものが使われてしまってエラーが起きることがある

type _CheckboxProps = { ... }

export const Checkbox = forwardRef<HTMLInputElement, _CheckboxProps> = forwardRef(...)

export type CheckboxProps = ComponentPropsWithRef<typeof Checkbox>

のように定義する

Qs-F avatar May 10 '23 10:05 Qs-F

asのキャストを使わずにもできそう ref: #1230

Qs-F avatar May 19 '23 00:05 Qs-F