Closed darewreck54 closed 7 years ago
One option that comes into my mind would be to render the component only on the client.
Agreed with @stephtr - you will need to put some logic around any code that tries to reference window
so that it doesn't run during server-side prerendering. For example, use a check like if (typeof window !== 'undefined') { ... run client-side code ... }
.
what about import 'xyz'. you can not put something like if in the import section
My use case was to use an external library wich attach an object to the global jQuery '$'. So it couldn't be used in server side. I finally added the import of the external lib only in the boot-client.ts file in order to being include only in client side.
@J0hnRoger How did you go about using that library elsewhere in your application after importing it in your boot-client.ts
file?
Hi,
I'm currently trying to use powerbi-client library in my reactredux application. However, when I use it i get the following exception:
Exception: Call to Node module failed with error: Prerendering failed because of error: ReferenceError: window is not defined
I believe this is because it tries to preRender some of the views and the views depend on a library that utilize the window object, but the window object does not exist on the server side.
Is disabling the prerender feature the only way to get around this problem? Any advice appreciated, Thanks, Derek