nicolaslopezj / react-meteor-data

Fetch Meteor data in React using decorators
38 stars 3 forks source link

Does this have a rendering out to SSR option? #7

Open pagesrichie opened 6 years ago

pagesrichie commented 6 years ago

The way you've structured this to work with decorators is an awesome idea.. I've implemented it in my test scenario, however any Meteor Method Data (not publication) that is grabbed from it does not show up when trying to send it to the server for SSR purposes.

I was trying to avoid doing SSR with method data by calling a meteor method twice. For example, in a blog type application, currently I have to write:

if(!Meteor.isClient) { const result = Meteor.call('Blog.findBlogData', paramsObjToSend) // save result to state and let the render() function use this data - this part is server side and this will show up for SSR! :) } else { Meteor.call('Blog.findBlogData', paramsObjToSend, (error, result) => { if(!error) { // save result to state and let the render() function use this data - however this part is client side, and will not show up for SSR. } }) }

It works the way I wanted and shows up in SSR, but runs the call twice - I was hoping your solution would allow me to send it in via props instead and not make me run the call twice to show up in SSR. In my test scenario, your solution does not show up when I view the source. Is there any way your solution can be tweaked to make it function for SSR purposes?

Thanks!