arunoda / react-komposer

Feed data into React components by composing containers.
MIT License
733 stars 70 forks source link

FlowRouter SSR + ReactKomposer #142

Open stewartcelani opened 7 years ago

stewartcelani commented 7 years ago

My app relies heavily on FlowRouter & ReactKomposer and I'd love a way for them to work together while doing SSR. This may be possible but there isn't any documentation out there.

From your SSR section in the React Komposer readme:

function postDataLoader(props, onData, env) {
   if (isSSR) {
      const data = fetchData();
      onData(null, data);
      return;
   }

   const stopSubscription = watchData((data) => {
      onData(null, data);
   });
   return stopSubscription;
}

How do we detect that the route is being rendered via SSR and thus flag isSSR to true?

What does the watchData function look like?

Coming from this kind of setup:

function mapMeteorToProps(props, onData) {
    const groupId = props.groupId
    if (Meteor.subscribe('Viewer').ready() && Meteor.subscribe("ClientEmails", groupId).ready() && Meteor.subscribe("LockExceptions").ready()) {
        [blah blah blah...]
        onData(null, {clients, cardZoomClient, lockExceptions, viewer})
    }
}
achtan commented 7 years ago

@stewartcelani hi, any luck with ssr ?

stewartcelani commented 7 years ago

@achtan Unfortunately not. Will probably do a rewrite and switch to react-router + rxjs or apollo.

neooleg commented 7 years ago

It seems isSSR mentioned within README.md is "alias" of Meteor.isServer

neooleg commented 7 years ago

However, watchData() function is still not found.

@arunoda could you please comment about it?