rescript-react
rescript-react copied to clipboard
Calling `React.forwardRef` with an unlabelled argument gives poor error message
Playground: https://rescript-lang.org/try?code=FA3C2D2AmCuA2BTABAIVgFw5AdsgvMgN7DLIACATogIYDGGAdHZOAA66I4anJIbJwNANYpCAJVoNGAM0iUA7jUrRJMgBTqARvBoALADTJqMgJQEAfMV5kAlgHMc8xOpOnSN5AB4tmbDisiACIggFoLSXomAGcMSlscewBfbwB6XyxcC14k9ySQKikmFnZObmB+QRExZHVzfEDeSpMCZEjpWGjENXUAKWjGADkEXR1ERlgcaEQZBMRody90TLwTfBbkVOykoA
Notice that the location of the error is invalid (Line 1, column -1)
Please if possible, don't use the React.forwardRef api. Use common props instead, as stated in the docs: https://rescript-lang.org/docs/react/latest/forwarding-refs
We will see how we can improve / deprecate the forwardRef api in the next JSX version
I think if this PR with commit is merged https://github.com/rescript-lang/syntax/pull/586/commits/c59520c59f53554beb843da3410954cf80d70a67, it will point the right location of source code about unlabelled ref in forwardRef.
But I agree on the comment from @ryyppy, please don't use the React.forwardRef API if possible 😃
Just tested with latest ReScript 10.1 build, and the location is indeed reported correctly now.