Iām not sure at what point itās required. ts
React.forwardRef does not seem to be able to take function components as arguments as types. As an implementation, it can.
function React.forwardRef<unknown, {}>(render: React.ForwardRefRenderFunction<unknown, {}>): React.ForwardRefExoticComponent<React.RefAttributes<unknown>>
FC as an argument will result in an error.
Argument of type āFC
ā is not assignable to parameter of type āForwardRefRenderFunction<unknown, Props>ā. ts
The same implementation is OK as long as the type is not declared as FC ts
Added on 2021-09-01
- This is just implicitly throwing out the second argument, ref, because thereās no type checking.
This page is auto-translated from /nishio/React.forwardRef using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. Iām very happy to spread my thought to non-Japanese readers.