Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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`
- Loading branch information
Showing
4 changed files
with
55 additions
and
24 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