Skip to content

FormField triggers errors when it has null as a child #7180

@kariwhitcomb

Description

@kariwhitcomb

Expected Behavior

We have code similar to this (without the explicit false)

<FormField>
        <TextInput />
        {false && <Text>foobar</Text>}
</FormField>

In v2.35.0 this would render fine with just the TextInput inside the form field

Actual Behavior

In v2.36.0 and v2.36.1 this code results in an error: 'Cannot read properties of null (reading 'props')'
It is failing around this line in FormField:

(child.props?.readOnly === true ||

URL, screen shot, or Codepen exhibiting the issue

https://codesandbox.io/p/sandbox/determined-noyce-yjhfjg?file=%2Fsrc%2FApp.js

Steps to Reproduce

  1. Have a FormField with a null or false child

Your Environment

  • Grommet version: v2.36.0 and v.2.36.1 (verified issue is present in both these versions)
  • Browser Name and version: Chrome
  • Operating System and version (desktop or mobile): Mac

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugissue that does not match design or documentation and requires code changes to address

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions