Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is ReactDOMServer increasing bundle size?

Tags:

reactjs

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";
like image 936
Alvaro Avatar asked Jul 11 '26 22:07

Alvaro


1 Answers

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.

like image 153
Naman Avatar answered Jul 13 '26 16:07

Naman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!