diff --git a/lib/server.jsx b/lib/server.jsx index 71e1401..c69b946 100644 --- a/lib/server.jsx +++ b/lib/server.jsx @@ -43,10 +43,11 @@ ReactRouterSSR.LoadWebpackStats = function(stats) { webpackStats = stats; }; -ReactRouterSSR.Run = function(routes, clientOptions, serverOptions) { - // this line just patches Subscribe and find mechanisms - patchSubscribeData(ReactRouterSSR); +// this line just patches Subscribe and find mechanisms +patchSubscribeData(ReactRouterSSR); +ReactRouterSSR.Run = function(routes, clientOptions, serverOptions) { + if (!clientOptions) { clientOptions = {}; } @@ -218,6 +219,11 @@ function generateSSRData(clientOptions, serverOptions, req, res, renderProps) { } if (!serverOptions.disableSSR){ + // I'm pretty sure this could be avoided in a more elegant way? + ReactDOMServer.renderToString(app); + const context = FastRender.frContext.get(); + const data = context.getData(); + InjectData.pushData(res, 'fast-render-data', data); html = ReactDOMServer.renderToString(app); } else if (serverOptions.loadingScreen){ html = serverOptions.loadingScreen; diff --git a/lib/ssr_context.js b/lib/ssr_context.js index a6c8574..2585fbb 100644 --- a/lib/ssr_context.js +++ b/lib/ssr_context.js @@ -1,8 +1,6 @@ // server/ssr_context.js // stolen from https://github.com/kadirahq/flow-router/blob/ssr/server/ssr_context.js -import deepMerge from 'deepmerge'; - export default class SsrContext { constructor() { this._collections = {}; @@ -26,8 +24,8 @@ export default class SsrContext { ); } - const args = [name].concat(params); - const data = fastRenderContext.subscribe(...args); + + const data = fastRenderContext.subscribe(name, ...params); this.addData(data); } @@ -38,9 +36,9 @@ export default class SsrContext { collData.forEach((item) => { const existingDoc = collection.findOne(item._id); if (existingDoc) { - const newDoc = deepMerge(existingDoc, item); + const newDoc = { ...existingDoc, ...item }; delete newDoc._id; - collection.update(item._id, newDoc); + collection.update(item._id, { $set: newDoc }); } else { collection.insert(item); } diff --git a/package.js b/package.js index c0e6f8f..d76a1d1 100644 --- a/package.js +++ b/package.js @@ -9,7 +9,6 @@ Package.describe({ Npm.depends({ 'cookie-parser': '1.4.1', 'cheerio': '0.20.0', - 'deepmerge': '0.2.10' }); Package.onUse(function(api) {