mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
- rename `unstable_after` -> `after` - remove `experimental.after` flag (and warn if it's present) i separated the big find-and-replace into a separate commit so that it's easier to see what else changed apart from that. does not touch docs, that's in #73038
36 lines
779 B
JavaScript
36 lines
779 B
JavaScript
import { after } from 'next/server'
|
|
import { cache } from 'react'
|
|
import { cliLog } from '../../../../utils/log'
|
|
|
|
const thing = cache(() => Symbol('cache me please'))
|
|
|
|
export default async function Index(props) {
|
|
const params = await props.params
|
|
const action = async () => {
|
|
'use server'
|
|
|
|
const valueFromAction = thing()
|
|
|
|
after(() => {
|
|
const valueFromAfter = thing()
|
|
|
|
cliLog({
|
|
source: '[action] /[id]/with-action',
|
|
value: params.id,
|
|
assertions: {
|
|
'cache() works in after()': valueFromAction === valueFromAfter,
|
|
},
|
|
})
|
|
})
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<h1>Page with after() in an action</h1>
|
|
<form action={action}>
|
|
<button type="submit">Submit</button>
|
|
</form>
|
|
</div>
|
|
)
|
|
}
|