-
I wonder whether using the custom previews by importing |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @sr258, that's an excellent question. In React Preview, preview(MyComponent, {
foo: somethingWithSideEffects()
}); In this particular case, webpack would be right not to eliminate the side effects (as would effectively modify application behaviour), and it would indeed have an impact on your bundle. In Preview.js (which will soon replace React Preview), To confirm this, you could build your application with and without a custom preview defined, and compare the generated bundles. Let me know if this makes sense! |
Beta Was this translation helpful? Give feedback.
Hey @sr258, that's an excellent question.
In React Preview,
preview
is implemented as a no-op function (see https://reactpreview.com/docs/features/custom-previews), so as long as webpack is configured to run tree shaking, that code shouldn't end up in your production bundle, unless you do something like:In this particular case, webpack would be right not to eliminate the side effects (as would effectively modify application behaviour), and it would indeed have an impact on your bundle.
In Preview.js (which will soon replace React Preview),
setupPreviews
is also implemented as a no-op function, but it allows you to pass a functi…