Skip to content

Commit b279797

Browse files
committed
fix: createRouterContextDataWrapper: arrow function messed up webpack-dev-server
1 parent b848ffa commit b279797

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-setup",
33
"description": "A Universal React setup with i18n: Babel 6, Koa 2, React, React Router, React Transmit, React Bootstrap, React-intl, Mocha, Webpack HMR, PostCSS, ESLint.",
4-
"version": "2.3.2",
4+
"version": "2.3.3",
55
"author": "Duc Nguyen (https://github.com/ngduc)",
66
"license": "MIT",
77
"homepage": "https://github.com/ngduc/react-setup",
@@ -68,7 +68,7 @@
6868
"koa-compose": "^3.0.0",
6969
"koa-compress": "^2.0.0",
7070
"koa-convert": "^1.2",
71-
"koa-generic-session": "^1.10",
71+
"koa-session": "^3.3.1",
7272
"koa-passport": "^2.0",
7373
"koa-router": "7.0.1",
7474
"koa-serve-static": "^1.0.0",

src/containers/App/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import jaLocaleData from 'react-intl/locale-data/ja'
88
addLocaleData(enLocaleData)
99
addLocaleData(jaLocaleData)
1010

11-
let currentLocale
11+
let currentLocale = 'en-US'
1212
let messages
1313

1414
export default class App extends React.Component {
1515
componentWillMount () {
1616
if (__CLIENT__) {
17-
currentLocale = (__CLIENT__ ? window.App.locale : 'en-US')
17+
currentLocale = window.App.locale
1818
messages = window.App.messages
1919
} else {
2020
currentLocale = this.context.data.i18nData.locale || 'en-US'

src/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Router from 'koa-router'
66
import serveStatic from 'koa-serve-static'
77
import koaConvert from 'koa-convert'
88
import koaCompress from 'koa-compress'
9-
//import koaSession from 'koa-session'
9+
import koaSession from 'koa-session'
1010
import zlib from 'zlib'
1111

1212
import routesContainer from 'containers/routes'
@@ -23,7 +23,7 @@ try {
2323
let routes = routesContainer
2424

2525
app.use(koaCompress({ flush: zlib.Z_SYNC_FLUSH }))
26-
//app.use(koaConvert(koaSession(app)))
26+
app.use(koaConvert(koaSession(app)))
2727

2828
app.use(apiRouter())
2929

src/server/libs/RouterContextDataWrapper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ export function createRouterContextDataWrapper (dataObj) {
77
childContextTypes: {
88
data: React.PropTypes.object.isRequired
99
},
10-
getChildContext: () => {
10+
getChildContext: function () {
1111
return {
1212
data: dataObj
1313
}
1414
},
15-
render: () => {
15+
render: function () {
1616
return <RouterContext { ...this.props } />
1717
}
1818
})

src/server/renderAppRouter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export default function renderAppRouter () {
2424
return next()
2525
}
2626

27-
const locale = ctx.query.locale || 'en-US'
28-
// ctx.session.locale = locale
27+
const locale = ctx.query.locale || ctx.session.locale || 'en-US'
28+
ctx.session.locale = locale
2929
i18nData = i18n.getLocaleMessages(locale)
3030
const i18nDataString = JSON.stringify(i18nData)
3131

0 commit comments

Comments
 (0)