I use content_for and partials in my layouts, and I was wondering how to add my React components same way I add partials using React.rb.
Thanks.
You would use react_component
in place of a partial.
So <%= react_component "Components::Foo", name: @user.name, rank: @user.rank %>
would mount the Components::Foo component at this point passing the users name, and rank.
There is no direct equivalent to content_for when bridging between layouts and react. Instead you would break the view into several component (one for each content_for block) and individually reference them using react_component.
Be aware that you can also directly mount the component from the controller, using the render_component
method in the controller.