Skip to content

[2.0.0-rc6] Variable ref inside a ref array is never assigned #3285

Description

@Azravos

Describe the bug

Doesn't work at all, elementRef never becomes assigned. But this is fully allowed by the type system and compiles

const MyComp = () =>
{
    let elementRef: HTMLDivElement | undefined
    
    return (
       <div ref={[
           elementRef
        ]}>
       </div>
    )
}

Works as intended

const MyComp = () =>
{
    let elementRef: HTMLDivElement | undefined
    
    return (
       <div ref={[
           el => elementRef = el
        ]}>
       </div>
    )
}

So I'm guessing either this is a bug or it simply shouldn't compile if it's not meant to be supported.

Your Example Website or App

See description

Steps to Reproduce the Bug or Issue

Just put a ref variable inside the ref array like ref={[myRef]} and it will never be assigned.

Expected behavior

Either a compile error if this isn't intended or the ref element to be successfully assigned

Screenshots or Videos

No response

Platform

  • OS: [Windows]
  • Browser: Chrome
  • Version: [152]

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions