-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add request callback in Flight client (#46650)
Adding the `callServer` option to Flight client with a naive implementation. Fixes NEXT-393. ## Bug - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
- Loading branch information
Showing
9 changed files
with
159 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
import { check } from 'next-test-utils' | ||
|
||
createNextDescribe( | ||
'app-dir action handling', | ||
{ | ||
files: __dirname, | ||
skipDeployment: true, | ||
}, | ||
({ next, isNextDev }) => { | ||
if (!isNextDev) { | ||
it('should create the server reference manifest', async () => { | ||
const content = await next.readFile( | ||
'.next/server/server-reference-manifest.json' | ||
) | ||
// Make sure it's valid JSON | ||
JSON.parse(content) | ||
expect(content.length > 0).toBeTrue() | ||
}) | ||
} | ||
|
||
// TODO: Ensure this works in production. | ||
if (isNextDev) { | ||
it('should handle basic actions correctly', async () => { | ||
const browser = await next.browser('/server') | ||
|
||
const cnt = await browser.elementByCss('h1').text() | ||
expect(cnt).toBe('0') | ||
|
||
await browser.elementByCss('#inc').click() | ||
await check(() => browser.elementByCss('h1').text(), '1') | ||
|
||
await browser.elementByCss('#dec').click() | ||
await check(() => browser.elementByCss('h1').text(), '0') | ||
}) | ||
} | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default function RootLayout({ children }) { | ||
return ( | ||
<html> | ||
<head /> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use server' | ||
|
||
export async function inc(value) { | ||
return value + 1 | ||
} | ||
|
||
export async function dec(value) { | ||
return value - 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use client' | ||
|
||
import { useState } from 'react' | ||
|
||
export default function Counter({ inc, dec }) { | ||
const [count, setCount] = useState(0) | ||
|
||
return ( | ||
<div> | ||
<h1>{count}</h1> | ||
<button | ||
id="inc" | ||
onClick={async () => { | ||
const newCount = await inc(count) | ||
setCount(newCount) | ||
}} | ||
> | ||
+1 | ||
</button> | ||
<button | ||
id="dec" | ||
onClick={async () => { | ||
const newCount = await dec(count) | ||
setCount(newCount) | ||
}} | ||
> | ||
-1 | ||
</button> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Counter from './counter' | ||
|
||
import { inc, dec } from './actions' | ||
|
||
export default function Page() { | ||
return <Counter inc={inc} dec={dec} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
experimental: { | ||
appDir: true, | ||
}, | ||
} |