Skip to content

Commit

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

8464456 to fix loading props in wrapperHook
dcf8176 corrected readme
5a1dae8 updated readme
5b5332c fixed SSR
9e750e9 updated components
532a174 updated react-router-ssr for meteor 1.4.2

git-subtree-dir: app/packages/meteor-react-router-ssr
git-subtree-split: 8464456f006a1cb0919bd678dfc280532687910d
  • Loading branch information
cdmbase committed Jan 6, 2017
1 parent 5697d0d commit 71a76eb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Your main `<Route />` node of your application.<br />
- `dehydrateHook` [function() : data]: Supply data that should be dehydrated and sent to client.
- `fetchDataHook` [function(components) : Array<Promise>]: Trigger the fetchData on your components that have it
- `preRender` [function(req, res)]: Executed just before the renderToString
- `dataLoader` [function(req, res, app)]: Executed just after the wrapperHook to populate any data.
- `postRender` [function(req, res)]: Executed just after the renderToString
- `dontMoveScripts` [bool]: Keep the script inside the head tag instead of moving it at the end of the body
- `disableSSR` [bool]: Disable server-side rendering, in case the application depends on code which doesn't work on the server.
Expand Down
8 changes: 5 additions & 3 deletions lib/client.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@ const ReactRouterSSR = {
});
}

let app = (
let appGenerator = (addProps) => (
<Router
history={history}
children={routes}
{...clientOptions.props} />
{...clientOptions.props}
{...addProps } />
);

let app;
if (typeof clientOptions.wrapperHook === 'function') {
app = clientOptions.wrapperHook(app);
app = clientOptions.wrapperHook(appGenerator);
}

if (typeof clientOptions.renderHook === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion lib/react-router-ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { checkNpmVersions } from 'meteor/tmeasday:check-npm-versions';
checkNpmVersions({
'react': '15.x',
'react-dom': '15.x',
'react-router': '2.x'
'react-router': '3.x'
}, 'reactrouter:react-router-ssr');

if (Meteor.isClient) {
Expand Down
13 changes: 10 additions & 3 deletions lib/server.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,18 @@ function generateSSRData(clientOptions, serverOptions, req, res, renderProps) {
...serverOptions.props
};

fetchComponentData(serverOptions, renderProps);
let app = <RouterContext {...renderProps} />;
// Instead of fetchComponentData we need to fetch from Apollo Data
//fetchComponentData(serverOptions, renderProps);
let appGenerator = (addProps) => <RouterContext {...renderProps} {...addProps} />;

let app;
if (typeof clientOptions.wrapperHook === 'function') {
app = clientOptions.wrapperHook(app);
app = clientOptions.wrapperHook(appGenerator);
}

// Adding new parameter dataLoader for loading data through Apollo
if (serverOptions.dataLoader) {
serverOptions.dataLoader(req, res, app);
}

if (!serverOptions.disableSSR){
Expand Down
8 changes: 4 additions & 4 deletions package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'reactrouter:react-router-ssr',
version: '3.1.5',
version: '3.1.6',
summary: 'Server-side rendering for react-router and react-meteor-data rehydratating Meteor subscriptions',
git: 'https://github.com/thereactivestack/meteor-react-router-ssr.git',
documentation: 'README.md'
Expand All @@ -18,8 +18,8 @@ Package.onUse(function(api) {
'ecmascript',
'tracker',
'[email protected]',
'meteorhacks:[email protected].0',
'meteorhacks:[email protected].0',
'staringatlights:[email protected].2',
'staringatlights:[email protected].4',
'tmeasday:[email protected]'
]);

Expand All @@ -34,7 +34,7 @@ Package.onUse(function(api) {
api.use([
'[email protected]',
'tmeasday:[email protected]',
'promise@0.5.1'
'promise@0.8.8'
], 'server', {weak: true})

api.export('ReactRouterSSR');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"react": "^15.3.0",
"react-dom": "^15.3.0",
"react-helmet": "^3.1.0",
"react-router": "^2.0.1",
"react-router": "^3.0.0",
"underscore": "^1.8.3"
}
}

0 comments on commit 71a76eb

Please sign in to comment.