You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You may be wondering why we're "client" loading data instead of loading the data on the server so we can do server-side rendering (SSR). Right now our contacts site is a [Single Page App][spa], so there's no server-side rendering. This makes it really easy to deploy to any static hosting provider, but we'll talk more about how to enable SSR in a bit so you can learn about all the different [rendering strategies][rendering-strategies] React Router offers.
462
462
@@ -519,13 +519,13 @@ export function HydrateFallback() {
519
519
520
520
Now if you refresh the page, you'll briefly see the loading splash before the app is hydrated.
When a route has children, and you're at the parent route's path, the `<Outlet>` has nothing to render because no children match. You can think of [index routes][index-route] as the default child route to fill in that space.
531
531
@@ -565,7 +565,7 @@ export default function Home() {
Remember the `:contactId` part of the route definition in `app/routes.ts`? These dynamic segments will match dynamic (changing) values in that position of the URL. We call these values in the URL "URL Params", or just "params" for short.
871
871
@@ -898,7 +898,7 @@ export default function Contact({
@@ -1110,7 +1110,7 @@ export async function action({
1110
1110
1111
1111
Fill out the form, hit save, and you should see something like this! <small>(Except easier on the eyes and maybe with the patience to cut watermelon.)</small>
@@ -1253,7 +1253,7 @@ export default function SidebarLayout({
1253
1253
1254
1254
Note that we are passing a function to `className`. When the user is at the URL that matches `<NavLink to>`, then `isActive` will be true. When it's _about_ to be active (the data is still loading) then `isPending` will be true. This allows us to easily indicate where the user is and also provide immediate feedback when links are clicked but data needs to be loaded.
@@ -1298,7 +1298,7 @@ export default function SidebarLayout({
1298
1298
1299
1299
In our case, we add a `"loading"` class to the main part of the app if we're not idle. The CSS then adds a nice fade after a short delay (to avoid flickering the UI for fast loads). You could do anything you want though, like show a spinner or loading bar across the top.
Because this is a `GET`, not a `POST`, React Router _does not_ call the `action` function. Submitting a `GET``form` is the same as clicking a link: only the URL changes.
1454
1454
@@ -1766,13 +1766,13 @@ export default function SidebarLayout({
1766
1766
1767
1767
You should now have a nice spinner on the left side of the search input.
Since the form is submitted for every keystroke, typing the characters "alex" and then deleting them with backspace results in a huge history stack 😂. We definitely don't want this:
Check that out, both stars automatically update. Our new `<fetcher.Form method="post">` works almost exactly like the `<Form>` we've been using: it calls the action and then all data is revalidated automatically — even your errors will be caught the same way.
0 commit comments