Skip to content

Commit

Permalink
Squashed 'app/packages/meteor-react-router-ssr/' changes from 8464456…
Browse files Browse the repository at this point in the history
…..6939eaf

6939eaf Merge pull request #2 from thereactivestack-legacy/master
27bb636 Merge pull request #94 from krizka/master
47a349b Merge pull request #90 from AirBorne04/patch-1
ef47394 Merge pull request #109 from cdmbase/master
d2c1785 Released 3.1.6
e64db68 update react-router dependency
40d9c49 make data available when using subscriptions inside createContainer
5d7e7cf - remove deepmerge dependency - deepMerge -> object construct
25e8dbb move the patch subscribe

git-subtree-dir: app/packages/meteor-react-router-ssr
git-subtree-split: 6939eafef4e4631655485e7f8480f168bad8df0e
  • Loading branch information
cdmbase committed Feb 11, 2017
1 parent 71a76eb commit efe65f3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
12 changes: 9 additions & 3 deletions lib/server.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
}
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions lib/ssr_context.js
Original file line number Diff line number Diff line change
@@ -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 = {};
Expand All @@ -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);
}

Expand All @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit efe65f3

Please sign in to comment.