Skip to content

Error using react-dom/server function renderToString #7033

@lennertcc

Description

@lennertcc

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

Windows

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

  • browser version
    Versie 90.0.818.66 (Officiële build) (64-bits)

  • SPFx version
    1.10.0

  • Node.js version
    v10.22.0

Describe the bug / error

When using
import { renderToString } from 'react-dom/server';

and running
gulp serve

the call to
const stringElement = renderToString(<SomeReactComponent key={index} />)

runs into

react-dom-server.browser.development.js:2543 
Uncaught TypeError: Cannot read property 'getCurrentStack' of undefined
    at pushCurrentDebugStack (react-dom-server.browser.development.js:2543)
    at ReactDOMServerRenderer.read (react-dom-server.browser.development.js:3138)
    at renderToString (react-dom-server.browser.development.js:3628)
    at MySPFxReactComponent.tsx:204

Steps to reproduce

See bug description

Expected behavior

When packaging the solution and using it from the App Catalog, this error does not occur and the renderToString function works as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:spfxCategory: SharePoint Framework (not extensions related)status:trackedCurrently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed)type:archive-old-issueIssues which are closed as tool old for active work

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions