News for hackers. Stuff that matters.
Re:The Performance Cost of Server Side Rendered React on Nod... by spinlock on Monday November 20, 2017 @07:58PM (#15744713)
Also, if you _need_ SSR, rails might be a better approach. It's too bad the author didn't include it in the benchmark.
Re:The Performance Cost of Server Side Rendered React on Nod... by lucaspiller on Tuesday November 21, 2017 @01:15AM (#15746026)
We did this recently with a small app that needs to be fast. The relatively simple page that you see when you first visit the site is rendered with plain old Rails, then when the user interacts with the page (based on DOM addEventListener hooks) it causes additional React components to be mounted and rendered.

Originally I’d hoped to be able to render a basic version of the page with Rails, then ‘enhance’ it with React - ie render <button>For</button> with Rails, then when React has loaded, replace it with a React component. But I couldn’t find any details on using it this way, and given time constraints choose the simplest option.

Re:The Performance Cost of Server Side Rendered React on Nod... by styfle on Tuesday November 21, 2017 @08:56AM (#15747835)
> then when React has loaded, replace it with a React component

What you described is basically `hydrate` which is how to enable React event handlers like onClick after a server-side render.

https://github.com/styfle/react-server-example-tsx/blob/4586...

Re:The Performance Cost of Server Side Rendered React on Nod... by scaryclam on Tuesday November 21, 2017 @11:11AM (#15748831)
This is something we've done in the past, and it works well. In fact, the ability to do this (usability is important to us so progressive enhancement is a lifesaver) is why we looked at react in the first place.