mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
If we run two or more actions, the first starts executing immediately, and the rest gets queued. The bug here was that if we navigated right after, the navigation would make us drop the rest of the queue, which would cause all the queued action calls to never resolve.
28 lines
579 B
TypeScript
28 lines
579 B
TypeScript
'use client'
|
|
|
|
import { useRouter } from 'next/navigation'
|
|
import { useState } from 'react'
|
|
import { myAction } from './server'
|
|
|
|
export default function Page() {
|
|
const router = useRouter()
|
|
const [text, setText] = useState('initial')
|
|
|
|
return (
|
|
<>
|
|
<button
|
|
type="button"
|
|
onClick={() => {
|
|
Promise.all([myAction(0), myAction(1)]).then(() => setText('done'))
|
|
setTimeout(() => {
|
|
router.replace('?')
|
|
})
|
|
}}
|
|
>
|
|
run actions
|
|
</button>
|
|
<div id="action-state">{text}</div>
|
|
</>
|
|
)
|
|
}
|