💡

Inertia v2.0.2 がリリースされていた

2025/01/15に公開

2.0.1がリリース

https://x.com/joetannenbaum/status/1879199918302322768

早速ブックを修正しつつ、試していくっ。割と修正点は多いみたい

現在の状態

$ ./vendor/bin/sail npm upgrade

$ ./vendor/bin/sail npm list --depth=0
html@ /var/www/html
+-- @headlessui/react@2.2.0
+-- @inertiajs/react@2.0.1
<snip>

とり急ぎ修正

https://github.com/inertiajs/inertia/issues/2152

closeされたので動作するはずということで

--- a/resources/js/Pages/InfiniteScroll.jsx
+++ b/resources/js/Pages/InfiniteScroll.jsx
@@ -3,7 +3,6 @@ import { Head, WhenVisible } from '@inertiajs/react';
 import { ClipLoader } from 'react-spinners';

 export default function InfiniteScroll({ users, currentPage, lastPage }) {
-  const randomKey = Math.random().toString(36).substr(2, 9);

   return (
     <DemoLayout
@@ -40,19 +39,18 @@ export default function InfiniteScroll({ users, currentPage, lastPage }) {
           {currentPage < lastPage && (
             <WhenVisible
               always
-              key={randomKey}
-              fallback={
-                <div className="flex items-center justify-center py-6">
-                  <ClipLoader size={35} color={'#2563eb'} />
-                </div>
-              }
               params={{
                 data: {
                   page: currentPage + 1,
                 },
                 only: ['users', 'currentPage'],
+                preserveUrl: true,
               }}
-            ></WhenVisible>
+            >
+                <div className="flex items-center justify-center py-6">
+                  <ClipLoader size={35} color={'#2563eb'} />
+                </div>
+            </WhenVisible>
           )}
         </section>
       </div>

うまいこと修正された。

あと、preserveUrl: trueもGETで動くようになりました(reactでも)

従って

urlに?page=1 ?page=2...とか付いてたのが消えてより洗練されたね!

https://zenn.dev/catatsumuri/books/8bc75eb68aabe8/viewer/a366c7

本を修正しておきました。リポジトリも

あとでもうちょい深入りするかも

https://github.com/inertiajs/inertia/issues/2025

これとかは対応されてないな

Discussion