rsnext/examples/active-class-name
Miroslav Petrov 47d2dfdb54
Update examples/active-class-name (#62506)
### Description
The current implementation of the activeClassName example doesn't
support the `UrlObject` type for the "href" Link prop.
For example
```
<ActiveLink
  activeClassName="active"
  className="nav-link"
  href={{
    pathname: "/[slug]",
    query: {
      slug: "dynamic-route",
    },
  }}
>
  Dynamic Route
</ActiveLink>
```
won't work.

### Suggestion
We can use the `resolveHref` function to handle all cases.

Co-authored-by: Sam Ko <sam@vercel.com>
2024-02-26 16:40:16 +00:00
..
components Update examples/active-class-name (#62506) 2024-02-26 16:40:16 +00:00
pages chore(examples): use default prettier for examples/templates (#60530) 2024-01-11 16:01:44 -07:00
.gitignore Add .yarn/install-state.gz to .gitignore (#56637) 2023-10-18 16:34:48 +00:00
next-env.d.ts Remove incorrect entries for pnpm debug log (#47241) 2023-03-26 22:26:05 -07:00
next.config.js chore(examples): use default prettier for examples/templates (#60530) 2024-01-11 16:01:44 -07:00
package.json chore(examples): fix active-class-name example (#37828) 2022-06-21 15:44:29 +00:00
README.md update example Deploy button URLs (#48842) 2023-04-26 13:31:44 -04:00
tsconfig.json Convert active-class-name example to TypeScript (#37676) 2022-06-14 08:49:09 +00:00

activeClassName example

ReactRouter has a convenience property on the Link element to allow an author to set the active className on a link. This example replicates that functionality using Next's own Link.

Deploy your own

Deploy the example using Vercel or preview live with StackBlitz

Deploy with Vercel

How to use

Execute create-next-app with npm, Yarn, or pnpm to bootstrap the example:

npx create-next-app --example active-class-name active-class-name-app
yarn create next-app --example active-class-name active-class-name-app
pnpm create next-app --example active-class-name active-class-name-app

Deploy it to the cloud with Vercel (Documentation).