I want to use ReactDOMServer.renderToStaticMarkup on the client side to turn some component into an HTML string (to use in a third party library) and I was wondering if adding the following will increase the bundle size or have any downsides on the performance or loading times:
import ReactDOMServer from "react-dom/server";
The best solution that is at least until dynamic import is safe for library use is to move getDataFromTree and renderToStringWithData into a separate bundle (react-apollo/server?) similar to how react-dom bundles all its server rendering logic in react-dom/server. This would avoid bundling extra react-dom logic for the vast majority of users who never call getDataFromTree from the browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With