Server side rendering and meteor call?

Hi,

I’m fetching data from a meteor call and I’m trying to render it server side with React.
Server side rendering works fine. But I don’t know how to manage the client side. I always end up with the following message:

Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:

Code example:

 ResultsLayout = React.createClass({
        
        mixins: [ReactMeteorData],
          getMeteorData(){
              var data = {};
              data.hits = Meteor.call("mymethod");
              return data;
          },
         render(){
            return <div>
             {(this.data.hits)? something() : "loading..."}
            </div>;
         }
)}

Any idea?

Meteor.call is called synchronously on the server and asynchronously on the client (http://docs.meteor.com/#/full/meteor_call). Which means that server received data from Meteor.call, but client didn’t. I guess all you need is to run Meteor.call asynchronously:

Meteor.call('mymethod', function(error, result) {
  data.hits = result;
});

This happens when your client side app does not have the correct data at first. Because in the client version, method takes sometime get the data.

So, your markup is something different for a moment. That’s why React is screaming. Try not to use data got from methods in the SSR stage.

Also in client, Meteor.call("mymethod"); doesn’t return data.

Calling the method asynchronously does not make any change.
I do understand the issue. But is there a way to pass down the data to the client, embedded as JSON, in the server generated page?

Try to use Meteor.subscribe as in this arunoda code.

Did you figure this one? I’m experiencing the same issue with server API calls