mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Update Angular2Spa and ReactReduxSpa to use aspnet-prerendering 2.0.0
This commit is contained in:
@@ -3,12 +3,12 @@ import { Provider } from 'react-redux';
|
||||
import { renderToString } from 'react-dom/server';
|
||||
import { match, RouterContext } from 'react-router';
|
||||
import createMemoryHistory from 'history/lib/createMemoryHistory';
|
||||
import { createServerRenderer, RenderResult } from 'aspnet-prerendering';
|
||||
import routes from './routes';
|
||||
import configureStore from './configureStore';
|
||||
type BootResult = { html?: string, globals?: { [key: string]: any }, redirectUrl?: string};
|
||||
|
||||
export default function (params: any): Promise<{ html: string }> {
|
||||
return new Promise<BootResult>((resolve, reject) => {
|
||||
export default createServerRenderer(params => {
|
||||
return new Promise<RenderResult>((resolve, reject) => {
|
||||
// Match the incoming request against the list of client-side routes
|
||||
match({ routes, location: params.location }, (error, redirectLocation, renderProps: any) => {
|
||||
if (error) {
|
||||
@@ -47,4 +47,4 @@ export default function (params: any): Promise<{ html: string }> {
|
||||
}, reject); // Also propagate any errors back into the host application
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"@types/webpack": "^1.12.35",
|
||||
"@types/webpack-env": "^1.12.1",
|
||||
"@types/whatwg-fetch": "0.0.28",
|
||||
"aspnet-prerendering": "^1.0.7",
|
||||
"aspnet-prerendering": "^2.0.0",
|
||||
"aspnet-webpack": "^1.0.17",
|
||||
"aspnet-webpack-react": "^1.0.2",
|
||||
"babel-core": "^6.5.2",
|
||||
|
||||
Reference in New Issue
Block a user