Bug: problem with ReactDomServer.renderToString
- Dominant language
- TypeScript
- Stars
- 23.9k
- Forks
- 2.2k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 61
Description
Hi,
I need to get the html structure from the lexical component using ReactDomServer.renderToString or ReactDomServer.renderToStaticMarkup
because I generate an html string from various components at the same time. The $generateHtmlFromNodes function won't help me because this returns an html string before being processed at the component level. I would then have to overdo it with the dangerouslySetInnerHTML function, which I don't want
the input to the editor component is JSON SerializedEditorState
it returns an warning
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client.
and output from renderToString is empty for lexical component
Please how could I solve this?
Well thank you
Contributor guide
Research direction
Start by reproducing the warning with ReactDomServer.renderToString and renderToStaticMarkup using the editor component and its JSON SerializedEditorState. Compare the result with $generateHtmlFromNodes; done would require an established server-rendering path that produces the component's HTML without the reported warning or empty output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100