rsnext/test/integration/script-loader/base/pages/page9.js
Sukka ed3cb83c8a
next/script: make onLoad concurrent rendering resilient (#40191)
Another step toward fixing #40025.

Multiple `next/script` components with the same `src` may exist in the
Next.js app. So the `loadScript` function will always attach the
`onLoad` handler to the `loadingPromise` every time it executes.

However, with strict mode (or wrapped inside the `<OffScreen />`
component), the `useEffect` could execute more than once for the same
`next/script` component, thus the `loadScript` for each `next/script`
component could execute more than once (and `onLoad` to be attached more
than once), results in `onLoad` fires more than once.

The PR makes sure that for every `next/script` component mounted, the
`loadScript` will always be executed only once for each of them.

The corresponding `onload fires correctly` integration test case is also
updated to run in dev mode.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-09-13 17:48:06 -07:00

12 lines
184 B
JavaScript

import Link from 'next/link'
const Page = () => {
return (
<>
<Link href="/page4">Page 4</Link>
<Link href="/page8">Page 8</Link>
</>
)
}
export default Page