Skip to content

Rails layout not applied when using render :component #1356

@leehoworko

Description

@leehoworko

When upgrading from Rails 7.2 to 8, we encountered an issue where controller layouts are no longer applied when using render :component with server-side rendering in react-rails. This document talks about this use case, specifically "By default, your current layout will be used and the component, rather than a view, will be rendered in place of yield."

In Rails 7.2.2.1 with react-rails 2.6.2, everything works as expected. The problem is introduced in Rails 8 due to a change in the render pipeline: the point at which layouts are applied has shifted. Specifically, the component renderer adds an inline key to the render options. In Rails 7.2, the layout was added before this step, so the presence of the inline key didn't affect the layout being applied. In Rails 8, the pipeline was altered so that the component renderer adds the inline key before the layout is applied, which prevents the layout from being included by default.

This is the Rails commit that introduced the change.

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