Closed andrewmumblebee closed 5 years ago
I did some further work on getting this to work, i used the script-loader
package for Webpack to ensure when i imported the interval-timeout-shim.js script it was being set in the global scope so that imported packages would use the shim defined functions.
Now React.net no longer crashes anytime i import a package that requires setTimeout, etc.
Please verify these steps before filing an issue, and check them off as you go
JavaScriptEngineSwitcher.V8.Native.win-x64
)SetUseReact
andSetUseBabel
is correct inReactConfig.cs
orStartup.cs
I'm using these library versions:
ReactJS.NET
: 5.0JavaScriptEngineSwitcher
: 3.1.0, ChakraCore 3.1.8 (Tried v8 aswell)react
andreact-dom
: (N/A if using bundled react, or version number)webpack
: 4.39.2Runtime environment:
I've got everything working with server side rendering of React, however, i've started to add animations to the components using the GSAP library.
This library makes heavy use of setTimeout, and as soon as i even just include it in a component that will be rendered server side, React.Net throws an exception with the error "SetTimeout is not supported in server-rendered Javascript.". The error will also throw any time setTimeout is referenced in my own code.
I noticed this is only thrown if
setTimeout
is not defined when the server rendering is being performed.src\React.Core\Resources\shims.js
I've tried to add the shim from https://gist.githubusercontent.com/ChadBurggraf/4c4abef515852aa1efee04478a8a8641/raw/8147e2c10567547b9c452382c3366352dc51cb1e/interval-timeout-shim.js which was referenced in #555 but i still get the same setTimeout error.
To elaborate i tried both loading the shim script in my startup.cs config chain.
And i've also tried adding it to my app.js bundle, setting the global object. But it still keeps crashing anytime setTimeout is used.
Any suggestions on how i can get around this issue? Cheers!