Inertia V2 + Rails - Infinite Scroll

Curated ago by @pedroaugustorduarte

Description

How to implement InfiniteScroll with Inertia V2 + Rails + Rails

1
2
3
4
5
6
7
8
9
10
11
class TodosController < ApplicationController

  # GET /todos or /todos.json
  def index
    @pagy, @todos   = pagy(Todo.all, limit: 10)
    render inertia: "Todos/Index", props: {
      todos: InertiaRails.merge(serialize(@todos, TodoSerializer)),
      pagy: @pagy,
    }
  end
end