Open JPeer264 opened 3 years ago
A little follow up on this one (and solution). It seems that streams should work perfectly (tried everything with renderToString). The thing is that this does not output the children (which makes total sense, as this should not be printed here).
I figured that there is a way to add third party support. In here we just need to add something in to interpolate (or any better name) with the children
within React.renderToStaticMarkup
like so:
// interpolate has a default: (input) => input
ReactDOMServer.renderToStaticMarkup(interpolate(children))
And in the usage it would look like (now without streams):
portals.appendUniversalPortals('', (children) => sheet.collectStyles(children));
@jesstelford I mentioned you here, because I cannot create an issue in your fork.
I saw in https://github.com/jesstelford/react-portal-universal/blob/43e9ba1e8e2ad84d55de6a43562d869c63fabafe/src/server.tsx#L26, that there is only support for
renderToStaticMarkup
. This works totally fine with stream when I put this instream.on('end', () => {})
.However, I am using
styled-components
to load stylesheets within my stream and using this function here https://github.com/styled-components/styled-components/blob/93a00472e3b9bf2974149e9d767e69e56659fbbb/packages/styled-components/src/models/ServerStyleSheet.js#L74.My guess now is that
interleaveWithNodeStream
fromstyled-components
never reaches the dom created byreact-portal-universal
and therefore it will never append the styles to it. I am not really sure if this following would be the solution to this problem.My current setup:
Possible solution: