Skip to content

React 18: bootstrapScriptContent escapes HTML so quotes can’t be used #23063

Closed
@calebmer

Description

@calebmer

If you use the bootstrapScriptContent option of renderToPipeableStream() to provide hydration data (as recommended in the <script> upgrade guide) with JSON.stringify() it doesn’t work because React escapes HTML characters in bootstrapScriptContent like quotes. I’ve worked around this by using backticks to deliniate strings.

What’s the correct thing to do here?

if (bootstrapScriptContent !== undefined) {
bootstrapChunks.push(
inlineScriptWithNonce,
stringToChunk(escapeTextForBrowser(bootstrapScriptContent)),
endInlineScript,
);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    React 18Bug reports, questions, and general feedback about React 18Type: Discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions