Open57

Web技術メモ

Josh NobusJosh Nobus
Josh NobusJosh Nobus

Remix でこれを設定する場合は app/entry.client.tsx に記述する。エントリーポイントなので、他にも Remix 外で設定したい項目があればここに追加してよい。

app/entry.client.tsx
/**
 * By default, Remix will handle hydrating your app on the client for you.
 * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
 * For more information, see https://remix.run/file-conventions/entry.client
 */

import { RemixBrowser } from "@remix-run/react";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";

window.addEventListener("beforeunload", (event: BeforeUnloadEvent) => {
  // ブラウザ再読み込み検知
  // event.preventDefault();
});

startTransition(() => {
  hydrateRoot(
    document,
    <StrictMode>
      <RemixBrowser />
    </StrictMode>
  );
});