Server rendering vs react routing?

Viewed 177

I'm trying Rails 6 and found it supports react and webpack very well so i can just render / serve react components from rails controller code: https://github.com/reactjs/react-rails#controller-actions

class TodoController < ApplicationController
  def index
    @todos = Todo.all
    render component: 'TodoList', props: { todos: @todos }
  end
end

That means I will have have web page routing defined on the server via rails routes and controllers (and at same time may still have these controller actions return json as REST api)

How's that compared to have the rails only serve a static page, and use react-router to switch between different react components?

It seems to me client-routing would have better performance as it will share the same redux store, and will not trigger a full page refresh?

0 Answers
Related