fixedForwardRef
functionfunction fixedForwardRef<T, P = {}>( render: (props: P, ref: React.Ref<T>) => React.ReactNode, ): (props: P & React.RefAttributes<T>) => React.ReactNode { return forwardRef(render) as any; }
fixedForwardRef
comes from Matt Pocock and is a bit more preferred as it won't leak into any code that imports your code.
ForwardRef
typedeclare module 'react' { function forwardRef<T, P = {}>( render: (props: P, ref: React.Ref<T>) => React.ReactNode, ): (props: P & React.RefAttributes<T>) => React.ReactNode; }
Here is a blog post explaining all this from the creator of this code Stefan Baumgartner