Skip to content

Commit 6086294

Browse files
committed
Update release notes
1 parent 7a4e20d commit 6086294

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ We manage release notes in this file instead of the paginated Github Releases Pa
1515
- [React Router Releases](#react-router-releases)
1616
- [v7.2.0](#v720)
1717
- [What's Changed](#whats-changed)
18+
- [Type-safe `href` utility](#type-safe-href-utility)
1819
- [Prerendering with a SPA Fallback](#prerendering-with-a-spa-fallback)
1920
- [Allow a root `loader` in SPA Mode](#allow-a-root-loader-in-spa-mode)
2021
- [Minor Changes](#minor-changes)
@@ -287,6 +288,36 @@ Date: 2025-02-13
287288

288289
### What's Changed
289290

291+
#### Type-safe `href` utility
292+
293+
In framework mode, we now provide you with a fully type-safe `href` utility to give you all the warm and fuzzy feelings of path auto-completion and param validation for links in your application:
294+
295+
```tsx
296+
import { href } from "react-router";
297+
298+
export default function Component() {
299+
const link = href("/blog/:slug", { slug: "my-first-post" });
300+
// ^ type-safe! ^ Also type-safe!
301+
302+
return (
303+
<main>
304+
<Link to={href("/products/:id", { id: "asdf" })} />
305+
<NavLink to={href("/:lang?/about", { lang: "en" })} />
306+
</main>
307+
);
308+
}
309+
```
310+
311+
You'll now get type errors if you pass a path path value or a bad param value:
312+
313+
```ts
314+
const badPath = href("/not/a/valid/path");
315+
// ^ Error!
316+
317+
const badParam = href("/blog/:slug", { oops: "bad param" });
318+
// ^ Error!
319+
```
320+
290321
#### Prerendering with a SPA Fallback
291322

292323
This release enhances the ability to use a combination of pre-rendered paths alongside other paths that operate in "SPA Mode" when pre-rendering with `ssr:false`.
@@ -309,6 +340,7 @@ In order to use your build-time loader data during pre-rendering, we now also ex
309340

310341
### Minor Changes
311342

343+
- `react-router` - New type-safe `href` utility that guarantees links point to actual paths in your app ([#13012](https://github.com/remix-run/react-router/pull/13012))
312344
- `@react-router/dev` - Generate a "SPA fallback" HTML file when pre-rendering the `/` route with `ssr:false` ([#12948](https://github.com/remix-run/react-router/pull/12948))
313345
- `@react-router/dev` - Allow a `loader` in the root route in SPA mode because it can be called/server-rendered at build time ([#12948](https://github.com/remix-run/react-router/pull/12948))
314346
- `Route.HydrateFallbackProps` now also receives `loaderData`
@@ -334,6 +366,14 @@ In order to use your build-time loader data during pre-rendering, we now also ex
334366
- When using `ssr:false` without a `prerender` config, only the `root` route can have a `loader`
335367
- When using `ssr:false` with a `prerender` config, only routes matched by a `prerender` path can have a `loader`
336368
- `@react-router/dev` - Limit prerendered resource route `.data` files to only the target route ([#13004](https://github.com/remix-run/react-router/pull/13004))
369+
- `@react-router/dev` - Fix typegen for repeated params ([#13012](https://github.com/remix-run/react-router/pull/13012))
370+
- In React Router, path parameters are keyed by their name, so for a path pattern like `/a/:id/b/:id?/c/:id`, the last `:id` will set the value for `id` in `useParams` and the `params` prop
371+
- For example, `/a/1/b/2/c/3` will result in the value `{ id: 3 }` at runtime
372+
- Previously, generated types for params incorrectly modeled repeated params with an array
373+
- For example, `/a/1/b/2/c/3` generated a type like `{ id: [1,2,3] }`.
374+
- To be consistent with runtime behavior, the generated types now correctly model the "last one wins" semantics of path parameters.
375+
- For example, `/a/1/b/2/c/3` now generates a type like `{ id: 3 }`.
376+
- `@react-router/dev` - Fix path to load `package.json` for `react-router --version` ([#13012](https://github.com/remix-run/react-router/pull/13012))
337377

338378
### Unstable Changes
339379

0 commit comments

Comments
 (0)