Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update readme to follow RR7 #51

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
docs: update readme to follow RR7
yusukebe committed Jan 4, 2025
commit 2d967e639ff8097abf429ad276b42ca5715c11b4
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -162,13 +162,13 @@ If you want to add extra context values when you use React Router routes, like i

```ts
// app/routes/_index.tsx
import type { Route } from './+types/_index'
import type { Route } from './+types/home'

export const loader = (args: Route.LoaderArgs) => {
return { extra: context.extra }
return { extra: args.context.extra }
}

export default function Index({ loaderData }: Route.ComponentProps) {
export default function Home({ loaderData }: Route.ComponentProps) {
const { extra } = loaderData
return <h1>Extra is {extra}</h1>
}
@@ -277,15 +277,15 @@ export default app
In the React Router route, you can get the context from `args.context.hono.context`:

```ts
// app/routes/_index.tsx
import { Router } from './types/_index'
// app/routes/home.tsx
import type { Route } from './+types/home'

export const loader = ({ context }) => {
export const loader = (args: Route.LoaderArgs) => {
const message = args.context.hono.context.get('message')
return { message }
}

export default function Index({ loaderData }: Route.ComponentProps) {
export default function Home({ loaderData }: Route.ComponentProps) {
const { message } = loaderData
return <h1>Message is {message}</h1>
}
@@ -366,7 +366,7 @@ export default app
You can retrieve and process the context saved in Hono from React Router as follows:

```ts
// app/routes/_index.tsx
// app/routes/home.tsx
import type { Env } from 'server'
import { getContext } from 'hono/context-storage' // It can be called anywhere for server-side processing.