Fix "Export SVG" feature in next 14 #4136
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Next.js version 14 currently throws an error when trying to export svg. The svg rendering uses a function renderToStaticMarkup from "react-dom/server" and next js decided it doesn't like seeing that in client code. Using a recommendation from the react docs goes some way towards fixing https://react.dev/reference/react-dom/server/renderToString#removing-rendertostring-from-the-client-code
xref vercel/next.js#58533 (comment)
fixes GMOD/jbrowse-react-app-nextjs-demo#1
Note: We still use renderToString in the web worker. We do not document web worker usage of our embedded components under nextjs though, but if this ever happened (#3730 ) then it may run into this, and the workaround in this PR would not work because it assumes existence of a
document
which does not exist in the web worker