I have a react component with forwardRef in TypeScript
const MyComponent= <TData, D extends ElementType = TableRowTypeMap['defaultComponent'],P = {}> (props :PropsWithForwardRef<TData, D, P>) => {
return ()
}
const FinalComponent: (<TData, D extends ElementType = TableRowTypeMap['defaultComponent'],P = {}>(props: PropsWithStandardRef<TData, D, P>) => ReactElement | null) =
forwardRef<ReactTableRef<any>, ReactTableProps<any, any, any>>((props, ref) => <MyComponent {...props} forwardedRef={ref} />);
export default FinalComponent;
I used This solution to do that, it works fine, but gets a type error (not stopping the application):
Type 'PropsWithForwardRef<any, any, any>' is not assignable to type 'PropsWithForwardRef<TData, D, P>'.
I think the solution is passing TData, D and P, but when I do:
const FinalComponent: (<TData, D extends ElementType = TableRowTypeMap['defaultComponent'],P = {}>(props: PropsWithStandardRef<TData, D, P>) => ReactElement | null) =
forwardRef<ReactTableRef<TData>, ReactTableProps<TData, D, P>>((props, ref) => <MyComponent {...props} forwardedRef={ref} />);
----- ----- - -
I've got error that: Cannot find names TData, D and P !!
Why? and What's the solution?