8000 forwardRef display name attached to incorrect function · Issue #635 · fable-hub/Feliz · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

forwardRef display name attached to incorrect function #635

New issue

8913 Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
joprice opened this issue Nov 7, 2024 · 0 comments
Open

forwardRef display name attached to incorrect function #635

joprice opened this issue Nov 7, 2024 · 0 comments

Comments

@joprice
Copy link
joprice commented Nov 7, 2024

When providing a name for a forwardRef, I see "Anonymous" as the display name. This seems to be caused by the extra wrapper function provided here https://github.com/Zaid-Ajaj/Feliz/blob/6841c9b150db7d73f1c9549ede07964949b5eaf0/Feliz/Internal.fs#L157.

Shadowing the render function to displayName to be set on the wrapper function sets the name correctly:

  let forwardRefWithName
    (name: string)                                                                                                                 (render: ('props * IRefValue<'t> -> ReactElement))                                                                             : ('props * IRefValue<'t> -> ReactElement)
    =
    let render =
      System.Func<'props, IRefValue<'t>, ReactElement>(fun props ref -> render (props, ref))
    let forwardRefType = Interop.reactApi.forwardRef (render)
    render?displayName <- name
    fun (props, ref) ->
      let propsObj = props |> JsInterop.toPlainJsObj
      propsObj?ref <- ref
      Interop.reactApi.createElement (forwardRefType, propsObj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0