how to reduce react createPortal import cost

147 Views Asked by At

import cost for createPortal from react-dom is 131kb (gzipped: 42kb)

i tried to import it as look like as createRoot that can import from "react-dom/client" but i can't do that. is there any way to reduce this cost?

2

There are 2 best solutions below

2
SeyMi On

No. it is exported from react-dom so you can't import it from react-dom/client. and the cost is not a big deal. why do you care about it at all?

0
ashalbulk On

Generally, if you use nextJS and care about the "First Load JS" size, it won't change with this import or without. So, you can use it as it is and sleep well. The bundle size is also the same.