Skip to content
This repository was archived by the owner on Jan 4, 2018. It is now read-only.

Commit a09a0ee

Browse files
committed
Merge pull request #52 from emmenko/babel-6
Babel 6
2 parents fdd0554 + a042d8a commit a09a0ee

28 files changed

+127
-106
lines changed

.babelrc

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
{
2-
"optional": ["runtime"],
3-
"stage": 0,
2+
"plugins": ["transform-runtime"],
3+
"presets": [ "es2015", "stage-0", "react" ],
44
"env": {
55
"development": {
6-
"plugins": ["react-transform"],
7-
"extra": {
8-
"react-transform": {
9-
"transforms": [{
10-
"transform": "react-transform-hmr",
11-
"imports": ["react"],
12-
"locals": ["module"]
13-
}]
14-
}
15-
}
6+
"plugins": [
7+
[ "react-transform", {
8+
"transforms": [
9+
{
10+
"transform": "react-transform-hmr",
11+
"imports": ["react"],
12+
"locals": ["module"]
13+
},
14+
{
15+
"transform": "react-transform-catch-errors",
16+
"imports": [ "react", "redbox-react" ]
17+
}
18+
]
19+
}]
20+
]
21+
},
22+
"i18n": {
23+
"plugins": [
24+
[ "react-intl", {
25+
"messagesDir": "./_translations",
26+
"enforceDescriptions": false
27+
}]
28+
]
1629
}
1730
}
1831
}

.babelrc.i18n

Lines changed: 0 additions & 10 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
http://emmenko.github.io/redux-react-router-async-example
22

3-
This is a boilerplate example showcasing _mostly_ [Redux](https://github.com/gaearon/redux) and [React Router](https://github.com/rackt/react-router).
3+
This is a boilerplate example showcasing _mostly_ [Redux](https://github.com/gaearon/redux) and [React Router](https://github.com/rackt/react-router) and it aims to provide different examples or use cases with the two libraries.
44

5-
> Still a **WIP** but it aims to provide different examples or use cases with the two libraries.
5+
##### The project will be constantly updated and improved with the latest dependencies, features, best practices and so on.
6+
7+
> Check out the [migration to babel 6](https://github.com/emmenko/redux-react-router-async-example/pull/52).
68
79
## Features
810

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# TODO
22

33
- JSDoc
4-
- better error handling
4+
- loading spinner for data fetching
55
- use inline styles https://github.com/emmenko/redux-react-router-async-example/issues/7
66
- add use-case for `AsyncProps`
77
- add use-case for external plugin https://dl.dropboxusercontent.com/u/4803975/ReactEurope/slides.pdf

lib/Root.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function getRootChildren (props) {
4848
]
4949

5050
if (__DEVTOOLS__) {
51-
const DevTools = require('./components/DevTools')
51+
const DevTools = require('./components/DevTools').default
5252
rootChildren.push(<DevTools key="devtools" />)
5353
}
5454
return rootChildren
@@ -90,15 +90,16 @@ function logout (nextState, replaceState) {
9090
replaceState({}, '/login')
9191
}
9292

93-
@connect(({ application }) => ({ application }))
94-
export default class Root extends React.Component {
93+
class Root extends React.Component {
9594
static propTypes = {
9695
application: PropTypes.object.isRequired
97-
}
96+
};
9897

9998
render () {
10099
return (
101100
<div>{getRootChildren(this.props)}</div>
102101
)
103102
}
104103
}
104+
105+
export default connect(({ application }) => ({ application }))(Root)

lib/components/Application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class Application extends React.Component {
88

99
static propTypes = {
1010
children: PropTypes.any
11-
}
11+
};
1212

1313
constructor (props, context) {
1414
super(props, context)

lib/components/DevTools.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import DockMonitor from 'redux-devtools-dock-monitor'
55

66
export default createDevTools(
77
<DockMonitor
8-
toggleVisibilityKey='H'
9-
changePositionKey='Q'>
8+
toggleVisibilityKey='ctrl-h'
9+
changePositionKey='ctrl-q'>
1010
<LogMonitor />
1111
</DockMonitor>
1212
)

lib/components/DisplayError.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class DisplayError extends React.Component {
77
static propTypes = {
88
hideError: PropTypes.func.isRequired,
99
error: PropTypes.object
10-
}
10+
};
1111

1212
render () {
1313
const { props: { hideError, error } } = this

lib/components/Menu.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ const menuItems = [
1313
{ text: 'Fork Me', link: GITHUB_REPO, icon: 'fa fa-github', isExternal: true }
1414
]
1515

16-
@connect(({ application }) => ({ application }), applicationActions)
17-
export default class Menu extends React.Component {
16+
class Menu extends React.Component {
1817

1918
static propTypes = {
2019
activeClass: PropTypes.string.isRequired,
2120
application: PropTypes.object.isRequired,
2221
switchLocale: PropTypes.func.isRequired
23-
}
22+
};
2423

2524
constructor (props, context) {
2625
super(props, context)
@@ -58,3 +57,8 @@ export default class Menu extends React.Component {
5857
)
5958
}
6059
}
60+
61+
export default connect(
62+
({ application }) => ({ application }),
63+
applicationActions
64+
)(Menu)

lib/components/MenuListItem.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export default class MenuListItem extends Component {
88
isExternal: PropTypes.bool,
99
link: PropTypes.string.isRequired,
1010
text: PropTypes.string.isRequired
11-
}
11+
};
1212

13-
static defaultProps = { isExternal: false }
13+
static defaultProps = { isExternal: false };
1414

1515
render () {
1616
return (

lib/components/github/Explore.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ export default class Explore extends React.Component {
2727
repo: PropTypes.string,
2828
username: PropTypes.string
2929
})
30-
}
30+
};
3131

3232
static contextTypes = {
3333
history: PropTypes.object.isRequired
34-
}
34+
};
3535

3636
constructor (props) {
3737
super(props)

lib/components/github/Pagination.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default class Pagination extends React.Component {
66
static propTypes = {
77
onPagination: PropTypes.func,
88
pagination: PropTypes.object
9-
}
9+
};
1010

1111
handlePaginationClick (link) {
1212
const page = link.url

lib/components/github/Repo.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@ import { fetchOnUpdate } from '../../decorators'
44
import StargazersUser from './StargazersUser'
55
import Pagination from './Pagination'
66

7-
@fetchOnUpdate([ 'username', 'repo' ], (params, actions) => {
8-
const { username, repo } = params
9-
actions.fetchRepo({ username, repo })
10-
actions.fetchRepoStargazers({ username, repo })
11-
})
12-
export default class Repo extends React.Component {
7+
class Repo extends React.Component {
138

149
static propTypes = {
1510
actions: PropTypes.object,
1611
github: PropTypes.object
17-
}
12+
};
1813

1914
render () {
2015
const { github: { repo, stargazers } } = this.props
@@ -87,3 +82,9 @@ export default class Repo extends React.Component {
8782
)
8883
}
8984
}
85+
86+
export default fetchOnUpdate([ 'username', 'repo' ], (params, actions) => {
87+
const { username, repo } = params
88+
actions.fetchRepo({ username, repo })
89+
actions.fetchRepoStargazers({ username, repo })
90+
})(Repo)

lib/components/github/StargazersRepo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default class StargazersRepo extends React.Component {
55

66
static propTypes = {
77
repo: PropTypes.object.isRequired
8-
}
8+
};
99

1010
render () {
1111
const { repo } = this.props

lib/components/github/StargazersUser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default class StargazersUser extends React.Component {
55

66
static propTypes = {
77
user: PropTypes.object.isRequired
8-
}
8+
};
99

1010
render () {
1111
const { user } = this.props

lib/components/github/User.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@ import { fetchOnUpdate } from '../../decorators'
44
import StargazersRepo from './StargazersRepo'
55
import Pagination from './Pagination'
66

7-
@fetchOnUpdate(['username'], (params, actions) => {
8-
const { username } = params
9-
actions.fetchUser({ username })
10-
actions.fetchUserStargazers({ username })
11-
})
12-
export default class User extends React.Component {
7+
class User extends React.Component {
138

149
static propTypes = {
1510
actions: PropTypes.object,
1611
github: PropTypes.object
17-
}
12+
};
1813

1914
render () {
2015
const { github: { user, stargazers } } = this.props
@@ -67,3 +62,9 @@ export default class User extends React.Component {
6762
)
6863
}
6964
}
65+
66+
export default fetchOnUpdate(['username'], (params, actions) => {
67+
const { username } = params
68+
actions.fetchUser({ username })
69+
actions.fetchUserStargazers({ username })
70+
})(User)

lib/components/pages/Account.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default class Account extends React.Component {
44

55
static propTypes = {
66
children: PropTypes.any
7-
}
7+
};
88

99
render () {
1010
return <div>{this.props.children}</div>

lib/components/pages/GithubStargazers.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,12 @@ const messages = defineMessages({
1313
}
1414
})
1515

16-
@connect(state => ({
17-
github: state.github
18-
}), dispatch => ({
19-
actions: bindActionCreators(githubActions, dispatch)
20-
}))
21-
export default class GithubStargazers extends React.Component {
16+
class GithubStargazers extends React.Component {
2217

2318
static propTypes = {
2419
children: PropTypes.any,
2520
actions: PropTypes.object
26-
}
21+
};
2722

2823
render () {
2924
return (
@@ -44,3 +39,8 @@ export default class GithubStargazers extends React.Component {
4439
)
4540
}
4641
}
42+
43+
export default connect(
44+
({ github }) => ({ github }),
45+
dispatch => ({ actions: bindActionCreators(githubActions, dispatch) })
46+
)(GithubStargazers)

lib/components/pages/Login.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ export default class Login extends React.Component {
55

66
static propTypes = {
77
location: PropTypes.object
8-
}
8+
};
99

1010
static contextTypes = {
1111
store: PropTypes.any,
1212
history: PropTypes.object.isRequired
13-
}
13+
};
1414

1515
constructor (props) {
1616
super(props)

lib/components/pages/SuperSecretArea.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ const messages = defineMessages({
1010
}
1111
})
1212

13-
@secure('manage_account')
14-
export default class SuperSecretArea extends React.Component {
13+
class SuperSecretArea extends React.Component {
1514
render () {
1615
return (
1716
<div>
@@ -25,3 +24,5 @@ export default class SuperSecretArea extends React.Component {
2524
)
2625
}
2726
}
27+
28+
export default secure('manage_account')(SuperSecretArea)

lib/decorators/fetchOnUpdate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function fetchOnUpdate (paramKeys, fn) {
1515
static propTypes = {
1616
actions: PropTypes.object,
1717
params: PropTypes.object
18-
}
18+
};
1919

2020
componentWillMount () {
2121
fn(mapParams(paramKeys, this.props.params), this.props.actions)

lib/decorators/secure.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function secure (scope) {
88

99
static contextTypes = {
1010
store: PropTypes.any
11-
}
11+
};
1212

1313
render () {
1414
const { store } = this.context

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ addLocaleData(it)
1818
// For that we need to patch in on runtime.
1919
if (!global.Intl)
2020
require.ensure(['intl'], require => {
21-
require('intl')
21+
require('intl').default
2222
start()
2323
}, 'IntlBundle')
2424
else start()

0 commit comments

Comments
 (0)