Skip to content

[Bug]: RadioButtonGroup crashes when passed null or undefined as child #16655

Closed
@brandones

Description

@brandones

Package

@carbon/react

Browser

Chrome

Package version

v11.58.1

React version

v1.58.1

Description

When I pass a null child to a RadioButtonGroup, it crashes. This is because of this line:

        const { value } = (radioButton as ReactElement)?.props ?? undefined;

which attempts to destructure undefined

Reproduction/example

https://stackblitz.com/edit/github-drap92?file=src%2FApp.jsx

Steps to reproduce

    <div>
      hi
      <RadioButtonGroup name="foo">
        <RadioButton labelText="hey" />
        {null}
      </RadioButtonGroup>
    </div>

Suggested Severity

Severity 3 = User can complete task, and/or has a workaround within the user experience of a given component.

Application/PAL

No response

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions