Skip to content

Commit cb869a4

Browse files
author
sky
committed
fix: egg view no state componet
1 parent 56f60a6 commit cb869a4

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

app/web/framework/app.tsx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +0,0 @@
1-
import React, { Component, ReactElement } from 'react';
2-
import ReactDOM from 'react-dom';
3-
import { AppContainer } from 'react-hot-loader';
4-
import Layout from './layout';
5-
6-
export default function bootstrap(App) {
7-
if (EASY_ENV_IS_NODE) {
8-
return props => <Layout {...props}><App {...props} /></Layout>;
9-
}
10-
const state = window.__INITIAL_STATE__;
11-
const root = document.getElementById('app');
12-
if (EASY_ENV_IS_DEV) {
13-
const render = c => {
14-
ReactDOM.hydrate(<AppContainer><App {...state} /></AppContainer>, root);
15-
};
16-
render(App);
17-
if (module.hot) {
18-
module.hot.accept();
19-
}
20-
}
21-
return ReactDOM.hydrate(<App {...state} />, root);
22-
}

app/web/page/home/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ import { AppContainer } from 'react-hot-loader';
55
import Layout from '../../framework/layout';
66
// https://github.com/gaearon/react-hot-loader/issues/525
77
import { Tab } from './component/tab';
8+
import { TabProps } from '../../framework/type';
9+
10+
class App extends Component<TabProps, any> {
11+
render() {
12+
return <Layout {...this.props}><Tab {...this.props} /></Layout>;
13+
}
14+
}
815

916
function bootstrap() {
1017
if (EASY_ENV_IS_NODE) {
11-
return props => <Layout {...props}><Tab {...props} /></Layout>;
18+
return App;
1219
}
1320
const state = window.__INITIAL_STATE__;
1421
const root = document.getElementById('app');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "egg-react-typescript-boilerplate",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "基于 egg + react + typescript + webpack 服务端渲染工程骨架项目",
55
"scripts": {
66
"start": "egg-scripts start",

0 commit comments

Comments
 (0)