Skip to content

Commit

Permalink
Merge branch 'canary' into canary
Browse files Browse the repository at this point in the history
  • Loading branch information
dydals3440 authored Dec 12, 2024
2 parents 73bfb6e + 6d05f24 commit 4466de9
Show file tree
Hide file tree
Showing 24 changed files with 434 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Expected errors are those that can occur during the normal operation of the appl

Use the `useActionState` hook to manage the state of Server Actions, including handling errors. This approach avoids `try`/`catch` blocks for expected errors, which should be modeled as return values rather than thrown exceptions.

```tsx filename="app/actions.ts" switcher
```ts filename="app/actions.ts" switcher
'use server'

import { redirect } from 'next/navigation'
Expand All @@ -36,7 +36,7 @@ export async function createUser(prevState: any, formData: FormData) {
}
```

```jsx filename="app/actions.js" switcher
```js filename="app/actions.js" switcher
'use server'

import { redirect } from 'next/navigation'
Expand Down
4 changes: 2 additions & 2 deletions docs/01-app/03-api-reference/04-functions/after.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ We recommend using `after` as it has been designed to consider other Next.js API

You can use request APIs such as [`cookies`](/docs/app/api-reference/functions/cookies) and [`headers`](/docs/app/api-reference/functions/headers) inside `after` in [Server Actions](/docs/app/building-your-application/data-fetching/server-actions-and-mutations) and [Route Handlers](/docs/app/api-reference/file-conventions/route). This is useful for logging activity after a mutation. For example:

```tsx filename="app/api/route.ts" highlight={2,7-9} switcher
```ts filename="app/api/route.ts" highlight={2,7-9} switcher
import { after } from 'next/server'
import { cookies, headers } from 'next/headers'
import { logUserAction } from '@/app/utils'
Expand All @@ -95,7 +95,7 @@ export async function POST(request: Request) {
}
```

```jsx filename="app/api/route.js" highlight={2,7-9} switcher
```js filename="app/api/route.js" highlight={2,7-9} switcher
import { after } from 'next/server'
import { cookies, headers } from 'next/headers'
import { logUserAction } from '@/app/utils'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/load-entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function loadEntrypoint(
for (const [innerKey, importPath] of Object.entries(
importMaps?.[key] || {}
)) {
file = `import ${key}_${innerKey} from "${importPath}"\n${file}`
file = `import ${key}_${innerKey} from ${JSON.stringify(importPath)}\n${file}`
importMapItems[key][innerKey] = `${key}_${innerKey}`
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/next/src/client/components/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -564,14 +564,14 @@ function Router({

const layoutRouterContext = useMemo(() => {
return {
childNodes: cache.parallelRoutes,
tree,
parentTree: tree,
parentCacheNode: cache,
parentSegmentPath: null,
// Root node always has `url`
// Provided in AppTreeContext to ensure it can be overwritten in layout-router
url: canonicalUrl,
loading: cache.loading,
}
}, [cache.parallelRoutes, tree, canonicalUrl, cache.loading])
}, [tree, cache, canonicalUrl])

const globalLayoutRouterContext = useMemo(() => {
return {
Expand Down
Loading

0 comments on commit 4466de9

Please sign in to comment.