GitXplorerGitXplorer
p

remix-hmr-example

public
10 stars
2 forks
0 issues

Commits

List of commits on branch main.
Verified
9fa4888fb72fcbae16716e479e9b7926c289c61e

update remix version to `nightly`

ppcattori committed 2 years ago
Unverified
eb10b832ca25a4de9e65478fe0d1a27cdc2efd80

add create-remix command to readme

ppcattori committed 2 years ago
Unverified
41a00b1ff53c5638d8bd0d5bc6a73a3a281d8a07

add counter to root and index routes

ppcattori committed 2 years ago
Unverified
59102237f495f4cfd1c3447d34f97b1909952885

styles for root route and index route

ppcattori committed 2 years ago
Unverified
d6be0974ad6e04eaf112c13c3c50fe852ec2a0bd

instructions for hmr + hdr

ppcattori committed 2 years ago
Unverified
47efebd66165e2325ddfa86a8f271b6a012a8d09

configure unstable_tailwind

ppcattori committed 2 years ago

README

The README file for this repository.

Remix HMR Example

This repo shows off Remix HMR + Hot Data Revalidation 🔥

Try it out!

npx create-remix@nightly --template pcattori/remix-hmr-example

Run it

npm run dev

Open up localhost:3000 to see your app

Change things!

Try changing things and getting hot updates!

Styles

Add a className to the <h1/> in app/routes/index.tsx:

<h1 className="bg-red-600">Welcome to Remix</h1>

Save the file and see them hot update. Feel free to keep changing them!

Markup

Add an <h2/> to app/routes/index.tsx:

<h2>blah</h2>

Or change the content in the <h1/>:

<h1 className="bg-red-600">Welcome to HMR + HDR 🔥</h1>

Data fetching

This is where the magic ✨ of HDR comes in.

Add a loader:

import { json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";

export let loader = () => json({ hello: "world" });

export default function Index() {
  let { hello } = useLoaderData<typeof loader>();
  return (
    <div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
      <h1>Welcome to Remix</h1>
      <h2>{hello}</h2>
      {/* rest of the code */}
    </div>
  );
}

Then try changing the loader data:

export let loader = () => json({ hello: "planet" });