TucsonReactJS / primer

A React Github searcher utility with a focus on idiomatic principles and the component life cycle
MIT License
1 stars 2 forks source link

Server Side Rendering #6

Open ScottBirgel opened 9 years ago

ScottBirgel commented 9 years ago

Hello, I know this isn't a topic for this example really but I am having trouble with my basic isomorphic app. I am fetching some data from a postgres database and trying render it server side by setting the component's state to the data fetched. The problem however, is that when the client re-renders that component it does not have the same prop to render with and fails to render the same content therefore I am not gaining the benefits of a true isomorphic app. How do I pass the data fetched from the server as a prop to the client? How does data fetching work in an isomorphic app?

bringking commented 9 years ago

Hey @ScottBirgel, not worries about the forum, don't mind attempting to answer this here.

*Once your app is mounted and running with the server passed state, it can take over and do everything from there.

Does that make some sense? It's hard to tell exactly without seeing you implementation, but that is it in a nutshell.

ScottBirgel commented 9 years ago

Yeah that makes sense thanks for the answer! ill have to check out express-state. Is the serialized state the key prop that is passed to react component that allows react to use its diff functions? Also do you prefer webpack over browserify? There are so many packages to choose from in the npm world. Also kinda off topic but do you use passport for auth in your apps?

Also, in general when is it appropriate to use server side rendering? And I have heard many mixed opinions about how search engine crawlers are smarter now because they check for changes to the DOM after running javascript. Should I use server side rendering simpley because of performance or will it actually have any effect on the app's SEO