Skip to content

React 19 - Invalid prop style supplied to React.Fragment. React.Fragment can only have key and children props. #6913

@0llirocks

Description

@0llirocks

Prerequisites

Describe the bug

Since React 19 we are getting the following error

Invalid prop style supplied to React.Fragment. React.Fragment can only have key and children props.

This only appears when we pass <></> to OverlayTrigger overlay like this

This works

<OverlayTrigger overlay={<Tooltip>{tooltipText}</Tooltip>} placement={placement}>
      <span>
             <Button disabled={disabled}>
                    Test
             </Button>
      </span>
</OverlayTrigger>

Produces the error

<OverlayTrigger overlay={<></>} placement={placement}>
      <span>
          <Button disabled={disabled}>
                    Test
           </Button>
      </span>
</OverlayTrigger>

The reason why we pass <></> is to disable the tooltip for this overlay, maybe this is the wrong approach and we should not render the OverlayTrigger at all if we have no tooltip? But sometimes we only want a tooltip if a button is disabled. In this case we need a non existing tooltip for the enabled button.

There was no error in react 18, if this is the correct behavior and we simply should not pass <></> we will fix our button component.

Expected behavior

No error appears.

To Reproduce

Use react 19

<OverlayTrigger overlay={<></>} placement={placement}>
      <span>
          <Button disabled={disabled}>
                    Test
           </Button>
      </span>
</OverlayTrigger>

Reproducible Example

sorry

Screenshots

No response

What operating system(s) are you seeing the problem on?

No response

What browser(s) are you seeing the problem on?

No response

What version of React-Bootstrap are you using?

2.8.0

What version of Bootstrap are you using?

5.3.0

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions