RickWong/react-transmit

React transmit components not getting rendered

pastelsky opened this issue · 2 comments

When I export the dumb component (React component), everything works fine, although, when exporting the container provided by react transmit, the component stops rendering and no error is shown.

Component

import React from "react";
import JsSdk from "../../api";
import Transmit from "react-transmit";

 class Search extends React.Component {
 /* exporting this class renders the component perfectly */
  render() {
    return (
      <div>
        <h1>Search Page { this.props.result.toString() }</h1>
      </div>
    );
  }
}

export default Transmit.createContainer /* Doesn't render */ (Search, {
  fragments: {
    result() {
      return JsSdk.search.suggestFor("Arab");
    },
  },
});

Server.js

app.use(function *(next) {
    yield ((callback) => {
      match({routes, location}, (error, redirectLocation, renderProps) => {

        Transmit.renderToString(RouterContext, renderProps).then(({reactString, reactData}) => {
          let template = (
            `<!doctype html>
                <html lang="en-us">
                    <body>
                        <div id="react-root">${reactString}</div>
                    </body>
                </html>`
          );
        this.body = template;
          callback(null);
        }).catch(e => {
          callback(e);
        });
      });
    });
  });

I'm having the same issue as well.

See #57 and #59, initialVariables must be defined on root containers even if you do not use any.