Skip to content

Commit

Permalink
fix Uncaught Error: Minified React error #418; visit https://react.d…
Browse files Browse the repository at this point in the history
…ev/errors/418` error due mismatch of last updated time date (#4060)

* fix `Uncaught Error: Minified React error #418; visit https://react.dev/errors/418` error due mismatch of last updated time date

* polish
  • Loading branch information
dimaMachina authored Jan 25, 2025
1 parent cbd6dc1 commit 20f7aaa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-days-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextra-theme-docs": patch
---

fix `Uncaught Error: Minified React error #418; visit https://react.dev/errors/418` error due mismatch of last updated time date
24 changes: 8 additions & 16 deletions docs/app/docs/guide/i18n/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
icon: GlobeIcon
---

import { ExampleCode } from '@components/example-code'
import { Steps } from 'nextra/components'

# Next.js I18n
Expand Down Expand Up @@ -56,30 +57,21 @@ i18n: [
]
```

## Automatically detect and redirect to user-selected language (optional)
## Automatically detect and redirect to user-selected language (_optional_)

You can automatically detect the user's preferred language and redirect them to
the corresponding version of the site. To achieve this, create a `middleware.js`
file in the root of your project and export Nextra's middleware function from
`nextra/locales`:

```js filename="middleware.js" {1}
export { middleware } from 'nextra/locales'

export const config = {
// Matcher ignoring `/_next/` and `/api/`
matcher: [
'/((?!api|_next/static|_next/image|favicon.ico|icon.svg|apple-icon.png|manifest).*)'
]
}
```
the corresponding version of the site. To achieve this, create a `middleware.ts`
or `middleware.js` file in the root of your project and export Nextra's
middleware function from `nextra/locales`:

<ExampleCode example="swr-site" filePath="middleware.ts" metadata="{1}" />

> [!WARNING]
>
> This approach will not work for i18n sites that are statically exported with
> `output: 'export'` in `nextConfig`.
## Custom 404 page (optional)
## Custom 404 page (_optional_)

You can have a custom `not-found.jsx` with translations for an i18n website that
uses a shared theme layout. For guidance on implementing this, you can check out
Expand Down
6 changes: 5 additions & 1 deletion packages/nextra-theme-docs/src/components/last-updated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export const LastUpdated: FC<{
return (
<>
{children}{' '}
<time dateTime={date.toISOString()}>
<time
dateTime={date.toISOString()}
// Can provoke React 418 error https://react.dev/errors/418
suppressHydrationWarning
>
{date.toLocaleDateString(dateLocale, {
day: 'numeric',
month: 'long',
Expand Down

0 comments on commit 20f7aaa

Please sign in to comment.