reactjs / React.NET

.NET library for JSX compilation and server-side rendering of React components
https://reactjs.net/
MIT License
2.3k stars 937 forks source link

Output from console.log during SSR is not reset between requests #1237

Open LinusCenterstrom opened 3 years ago

LinusCenterstrom commented 3 years ago

Thanks for filing a bug! To save time, if you're having trouble using the library, please check off the items you have tried. If you are just asking a question, skip right to the bottom.

Please verify these steps before filing an issue, and check them off as you go

I'm using these library versions:

Steps to reproduce / description

make sure to enable reuse of javascript engines. SetReuseJavaScriptEngines(true)

render a simple component that logs something.

function Comp(){
     console.log("test");
     return <div>Hello World!</div>;
}

and refresh the page a few times. You'll notice you get one more console.log for each page refresh. (Until the javascript engine is reset)

Suggested fix: Either expose a method that resets the console calls array or you could just make console.getCalls empty the array of calls, since I don't see a situation where you'd want to get the same calls more than once.

cb-eli commented 3 years ago

Happened to me as well... even when the component called console.log is not rendered in the next requests, the console.log message still appears.

Daniel15 commented 3 years ago

Hmmm... It's likely that this has been a problem ever since engine pooling was added to the library. The data stored in the log shim needs to be cleared after the request.