Skip to content

before_render should respect render? #2718

Description

@sineway

Steps to reproduce

class TestComponent < ViewComponent::Base
  def render?
    false
  end

  def before_render
    puts '--------------------'
    puts 'push data into slots'
    puts '--------------------'
  end

  def call
    content
  end
end

Expected behavior

before_render is not called because render? returns false

Actual behavior

before_render is always called

Backtrace:

System configuration

Rails version:
7.2.3.2

Ruby version:
3.4.9

Gem version:
4.12.0

Activity

  1. linked a pull request that will close this issueSkip before_render when render? returns false #2719on Oct 9, 2026
  2. joelhawksley commented on Oct 9, 2026

    @joelhawksley
    Member

    I confirmed in #2719 that this would be a breaking change. Closing as wontfix ❤️

    If you think we should update the docs, please sent a PR!

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

Metadata

Metadata

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