Upgrade React and React Router
This commit is contained in:
parent
ef8e8ca59e
commit
c96b4b624b
12 changed files with 218 additions and 134 deletions
|
@ -1,5 +1,5 @@
|
|||
import React from 'react';
|
||||
import createHandler from './react-handler';
|
||||
import { renderPage } from './react-handler';
|
||||
|
||||
import debuglog from 'debug';
|
||||
const debug = debuglog('match.audio');
|
||||
|
@ -11,12 +11,7 @@ export default function (routes) {
|
|||
yield next;
|
||||
} catch (err) {
|
||||
if (err.status === 404) {
|
||||
let Handler = yield createHandler(routes, this.request.url);
|
||||
|
||||
let App = React.createFactory(Handler);
|
||||
let content = React.renderToString(new App());
|
||||
|
||||
this.body = '<!doctype html>\n' + content;
|
||||
this.body = yield renderPage(routes, this.request.url, {});
|
||||
} else {
|
||||
debug('Error: %o', err);
|
||||
throw err;
|
||||
|
@ -28,12 +23,7 @@ export default function (routes) {
|
|||
switch (this.accepts('html', 'json')) {
|
||||
case 'html':
|
||||
this.type = 'html';
|
||||
let Handler = yield createHandler(routes, this.request.url);
|
||||
|
||||
let App = React.createFactory(Handler);
|
||||
let content = React.renderToString(new App());
|
||||
|
||||
this.body = '<!doctype html>\n' + content;
|
||||
this.body = yield renderPage(routes, this.request.url, {});
|
||||
break;
|
||||
case 'json':
|
||||
this.body = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue