Skip to content

Commit

Permalink
Modified babel plugin for server according to changing from redux to …
Browse files Browse the repository at this point in the history
…mobx.
  • Loading branch information
jbpark committed Mar 8, 2018
1 parent 26b6b5d commit 8815c7c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ OS 환경에 맞는 [nodejs](https://nodejs.org/ko/) 설치가 필요합니다.
```
npm run build
```
### 소스 빌드 후 SSR 서버 실행
### 소스 빌드 후 개발 서버 실행
```
npm run serve
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-app-rewired eject",
"serve": "yarn build && node server/index.js"
"serve": "yarn build && NODE_ENV=development node server/index.js"
},
"devDependencies": {
"axios": "^0.18.0",
Expand Down
1 change: 1 addition & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require('babel-register')({
"react-loadable/babel",
"dynamic-import-node",
"syntax-dynamic-import",
"transform-decorators-legacy"
// ["import-inspector", {
// "serverSideRequirePath": true
// }]
Expand Down
2 changes: 1 addition & 1 deletion src/client/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import App from '../App';
// import store from '../redux/store';

// mobx
import Store from '../mobx/Store';
import { Provider } from 'mobx-react';
import Store from '../mobx/Store';
const store = new Store();

const Root = () => (
Expand Down
8 changes: 6 additions & 2 deletions src/server/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import { Helmet } from 'react-helmet';
// import store from '../redux/store';

// mobx
import { toJS } from 'mobx';
import { Provider } from 'mobx-react';
import Store from '../mobx/Store';
const store = new Store();

const render = async (location) => {
const store = new Store();
const helmet = Helmet.renderStatic();
const context = {};

Expand All @@ -27,7 +28,10 @@ const render = async (location) => {

return {
html,
state: store.getState(),
// redux
// state: store.getState(),
// mobx
state: toJS(store),
helmet,
};
};
Expand Down

0 comments on commit 8815c7c

Please sign in to comment.