[React] forwardRef typescript

import React, { forwardRef } from "react";
// Declare a type that works with generic components
type FixedForwardRef = <T, P = {}>(
render: (props: P, ref: React.Ref<T>) => React.ReactElement
) => (props: P & React.RefAttributes<T>) => React.ReactElement;

// Cast the old `forwardRef` to the new one
export const fixedForwardRef =
forwardRef as FixedForwardRef;

 

posted @ 2023-08-01 14:11  Zhentiw  阅读(65)  评论(0)    收藏  举报