#Separating types from js: React forwardRef
9 messages · Page 1 of 1 (latest)
Preview:```ts
import React, {
ComponentType,
forwardRef,
ForwardRefExoticComponent,
PropsWithoutRef,
RefAttributes,
} from "react"
// Variant 1: with forwardRef
namespace V1 {
const withFoo = <P extends JSX.IntrinsicAttributes>(
Component: ComponentType<P>
)
...```
I cannot understand why it's not working? I did everything properly, did I?
What's the goal of "separating the types from the JS"?
I don't see an obvious error there; but it's a fairly complex type so it might be easy to miss something minor.
Preview:```ts
import React, {ComponentType, forwardRef} from "react"
// Variant 1: with forwardRef
namespace V1 {
const withFoo = <P extends JSX.IntrinsicAttributes>(
Component: ComponentType<P>
) =>
forwardRef<HTMLFormElement, P>((props, ref) => {
return
...```