Skip to content

Conversation

@AbanoubGhadban
Copy link
Collaborator

@AbanoubGhadban AbanoubGhadban commented Nov 12, 2025

Summary

Remove this paragraph and provide a general description of the code changes in your pull
request... were there any bugs you had fixed? If so, mention them. If
these bugs have open GitHub issues, be sure to tag them here as well,
to keep the conversation linked together.

Pull Request checklist

Remove this line after checking all the items here. If the item is not applicable to the PR, both check it out and wrap it by ~.

  • Add/update test to cover these changes
  • Update documentation
  • Update CHANGELOG file

Add the CHANGELOG entry at the top of the file.

Other Information

Remove this paragraph and mention any other important and relevant information such as benchmarks.


This change is Reviewable

Move immediate_hydration from ReactOnRails to ReactOnRailsPro
configuration since it's a Pro-only feature.

Changes:
- Add DEFAULT_IMMEDIATE_HYDRATION constant (default: false)
- Add immediate_hydration to attr_accessor list
- Add immediate_hydration parameter to initialize method
- Add immediate_hydration assignment in initialize
- Add immediate_hydration to configuration instantiation

This prepares for removing immediate_hydration from the core
ReactOnRails configuration in the next commit.
Add a helper method to access the immediate_hydration configuration
from ReactOnRailsPro when Pro is available.

Changes:
- Add immediate_hydration_config class method that returns false
  when Pro is not available, or ReactOnRailsPro.configuration.
  immediate_hydration when Pro is available
- Update disable_pro_render_options_if_not_licensed to use the
  new helper instead of accessing ReactOnRails.configuration

This prepares for removing immediate_hydration from ReactOnRails
configuration.
Update all code that accesses immediate_hydration configuration
to use the new ProUtils.immediate_hydration_config helper.

Changes:
- helper.rb: Use ProUtils.immediate_hydration_config in redux_store
- controller.rb: Use ProUtils.immediate_hydration_config in redux_store
- render_options.rb: Update immediate_hydration method to use
  ProUtils.immediate_hydration_config instead of retrieve_configuration_value_for

This prepares for removing immediate_hydration from the ReactOnRails
configuration class.
This removes immediate_hydration config from the core ReactOnRails
configuration as it is now managed by ReactOnRailsPro::Configuration.
All code now uses ReactOnRails::ProUtils.immediate_hydration_config
to access the Pro configuration value.
Moves immediate_hydration configuration check from ReactOnRails config
analysis to ReactOnRailsPro config analysis. The doctor now reads the
react_on_rails_pro.rb initializer file to display immediate_hydration
settings when the Pro package is configured.
Changes test setup to stub ReactOnRails::ProUtils.immediate_hydration_config
instead of setting config.immediate_hydration on ReactOnRails configuration.
This aligns with the new architecture where immediate_hydration is a Pro-only
configuration option.

Also removes config.immediate_hydration from the dummy app initializer as it
is no longer a valid ReactOnRails configuration option.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/move-immediate-hydration-to-pro-011CV4Fb98f7Cdn9uPm4ACU6

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Nov 12, 2025

Code Review: Move immediate_hydration to Pro

Summary

This PR successfully migrates the immediate_hydration configuration option from the open-source React on Rails gem to React on Rails Pro, properly implementing it as a licensed feature.


✅ Strengths

1. Clean Architecture

  • The new ProUtils.immediate_hydration_config method provides a centralized, safe accessor that returns false when Pro is not available
  • Excellent encapsulation - all Pro feature checks go through a single helper method
  • The pattern is reusable for future Pro-only features

2. Comprehensive Migration

  • Removed immediate_hydration from 5 locations in open-source configuration: Configuration.configuration_hash, attr_accessor, initialize, defaults, and the dummy app
  • Added it properly to Pro configuration with DEFAULT_IMMEDIATE_HYDRATION = false
  • Updated all 3 call sites (controller.rb, helper.rb, render_options.rb) to use the new helper

3. Test Quality Improvements

  • Excellent refactor in test files: replaced around hooks that modified global config with cleaner allow().to receive() stubs
  • Tests are now isolated and don't pollute global configuration state
  • This is a best practice improvement beyond the core requirements

4. Documentation Updates

  • The doctor.rb diagnostic tool now properly separates Pro config from open-source config
  • Shows immediate_hydration status in Pro initializer check
  • Removed Pro feature from performance config section (appropriate separation)

🔍 Potential Issues

1. Logic Error in pro_utils.rb (line 28-30) ⚠️

option_enabled = if raw_options[option].nil?
                   # Use the Pro config helper to get the global config value
                   immediate_hydration_config

Problem: This hardcodes immediate_hydration_config for ALL options in PRO_ONLY_OPTIONS, but the method should be dynamic.

Current behavior: Works only because PRO_ONLY_OPTIONS = %i[immediate_hydration] has one element
Future bug: If you add streaming_ssr: true to PRO_ONLY_OPTIONS, it will incorrectly use immediate_hydration_config

Fix:

option_enabled = if raw_options[option].nil?
                   # Dynamically call the Pro config method for this specific option
                   method_name = "\#{option}_config"
                   respond_to?(method_name, true) ? send(method_name) : false
                 else
                   raw_options[option]
                 end

Or simpler for now:

option_enabled = if raw_options[option].nil?
                   send("\#{option}_config")
                 else
                   raw_options[option]
                 end

2. Missing CHANGELOG Entry 📋
Per CLAUDE.md:

Update CHANGELOG.md for user-visible changes only (features, bug fixes, breaking changes, deprecations, performance improvements)

This is a breaking change for users who:

  • Use immediate_hydration without Pro license (it will silently stop working)
  • Have config.immediate_hydration = true in their open-source initializer (it will raise an error)

Suggested entry:

#### [PR 1996](https://github.com/shakacode/react_on_rails/pull/1996) by [AbanoubGhadban](https://github.com/AbanoubGhadban)

**Breaking Change:** The `immediate_hydration` configuration option is now a React on Rails Pro exclusive feature. If you were using this option without a Pro license, you'll need to either:
1. Remove `config.immediate_hydration = true` from your `config/initializers/react_on_rails.rb`
2. Upgrade to React on Rails Pro and move the setting to `config/initializers/react_on_rails_pro.rb`

The option will be silently ignored if Pro is not installed.

3. PR Description is Template Text 📝
The PR body is still the default template. Please update with:

  • What this PR does (moves immediate_hydration to Pro)
  • Why (it's a licensed feature)
  • Any migration steps for users

🎯 Security & Performance

Security: ✅ No concerns. The feature gracefully degrades when Pro is not licensed.

Performance: ✅ Negligible impact. The immediate_hydration_config method is called during component rendering setup, not in hot paths.


📊 Test Coverage

Current coverage: ✅ Good

  • Tests properly stub the new helper method
  • Integration tests verify behavior with Pro features enabled

Recommendation: Consider adding a test case for:

context "when Pro is not available" do
  it "returns false for immediate_hydration_config" do
    allow(ReactOnRails::ProUtils).to receive(:support_pro_features?).and_return(false)
    expect(ReactOnRails::ProUtils.immediate_hydration_config).to eq(false)
  end
end

📋 Pre-Merge Checklist

Per CLAUDE.md, before merging:

  • Run bundle exec rubocop and fix all violations
  • Ensure all files end with newlines
  • Update PR description (remove template text)
  • Add CHANGELOG entry for breaking change
  • Fix the logic bug in pro_utils.rb:28-30
  • Consider using /update-changelog command for guided changelog update

🎉 Overall Assessment

Quality: High - clean refactoring with good test practices
Risk: Medium - breaking change requires clear communication to users
Recommendation: Approve after addressing the logic bug and adding CHANGELOG entry

The architecture is solid and sets a good pattern for future Pro features. The test improvements (using stubs instead of global config mutation) are a welcome bonus. Great work! 🚀

@justin808
Copy link
Member

See #1997.

@justin808 justin808 closed this Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants