UNPKG

882 BJavaScriptView Raw
1import React from 'react';
2
3import Controller from './controller';
4import Wrap from './wrappedPage';
5
6// A reactController is also a React component.
7// Define a `render` function at minimum. In this case, we want to
8export default class ReactController extends Controller {
9 layout = null;
10 page = null;
11
12 // Use `render` to return the contents of `this.page`. In this example, we're
13 // going to use React, so we'll just return a React element. `render` async.
14 render () {
15 const { ctx } = this;
16 const Page = this.page;
17 const PageLayout = this.pageLayout;
18
19 const props = ctx.props;
20
21 let Layout;
22
23 if (ctx.includeLayout && this.layout) {
24 Layout = this.layout;
25 }
26
27 return (
28 <Wrap
29 { ...props }
30 Layout={ Layout }
31 PageLayout={ PageLayout }
32 Page={ Page }
33 key={ Math.random() }
34 />
35 );
36 }
37}