Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script with "beforeInteractive" strategy and innerHTML rendered incorrectly. #26240

Closed
lxsmnsyc opened this issue Jun 17, 2021 · 3 comments · Fixed by #36364
Closed

Script with "beforeInteractive" strategy and innerHTML rendered incorrectly. #26240

lxsmnsyc opened this issue Jun 17, 2021 · 3 comments · Fixed by #36364
Labels
bug Issue was opened via the bug report template.

Comments

@lxsmnsyc
Copy link

What version of Next.js are you using?

11.0.0

What version of Node.js are you using?

15.4.0

What browser are you using?

Chrome

What operating system are you using?

Windows

How are you deploying your application?

next dev

Describe the Bug

Scripts with "beforeInteractive" strategy and dangerouslySetInnerHTML or inlined script incorrectly renders scripts in SSR.

Code:

import '../styles/globals.css'
import type { AppProps } from 'next/app'
import Script from 'next/script'

function MyApp({ Component, pageProps }: AppProps) {
  return (
    <>
      <Component {...pageProps} />
      <Script strategy="beforeInteractive">
        {'console.log("DYNAMIC INLINE SCRIPT RENDERED");'}
      </Script>
      <Script
        strategy="beforeInteractive"
        dangerouslySetInnerHTML={{ __html: 'console.log("dangerouslySetInnerHTML SCRIPT RENDERED");' }}
      />
    </>
  )
}

export default MyApp

Output (notice the src(unknown)
image

Codesandbox: https://codesandbox.io/s/github/LXSMNSYC/next-script-beforeinteractive-repro

Expected Behavior

It should correctly render the scripts on server-side.

To Reproduce

Reproduction mentioned and linked above

@lxsmnsyc lxsmnsyc added the bug Issue was opened via the bug report template. label Jun 17, 2021
@lxsmnsyc lxsmnsyc changed the title Script with "beforeInteractive" strategy and innerHTML not being pre-rendered correctly. Script with "beforeInteractive" strategy and innerHTML rendered incorrectly. Jun 17, 2021
@lxsmnsyc

This comment has been minimized.

@devanshj
Copy link

devanshj commented Nov 3, 2021

Probably it's because of facebook/react#13838

@kodiakhq kodiakhq bot closed this as completed in #36364 Apr 29, 2022
kodiakhq bot pushed a commit that referenced this issue Apr 29, 2022
…eforeInteractive` strategies (#36364)

Adds inline script functionality to `next/script` for `worker` and `beforeInteractive` strategies. 

- fixes #36318 
- fixes #26343
- fixes #26591
- fixes #26343
- fixes #26240


Co-authored-by: Janicklas Ralph <[email protected]>
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
2 participants