Skip to content

Commit 3207fb4

Browse files
committed
Update npm modules; fix ESLint warnings; prefer functional stateless components
1 parent e08dba0 commit 3207fb4

File tree

9 files changed

+95
-98
lines changed

9 files changed

+95
-98
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
44

55
### [Unreleased][unreleased]
66

7+
- Convert `Feedback`, `Footer`, `Header`, and `Navigation` to functional stateless components
78
- Move page / screen components into the `src/routes` folder along with the routing information for them [BREAKING CHANGE]. [6553936](https://github.com/kriasoft/react-starter-kit/commit/6553936e693e24a8ac6178f4962af15e0ea87dfd)
89

910
### [v0.5.1] - 2016-03-02

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"front-matter": "2.0.6",
2121
"graphiql": "0.5.0",
2222
"graphql": "0.4.18",
23-
"history": "2.0.0",
24-
"isomorphic-style-loader": "0.0.10",
23+
"history": "2.0.1",
24+
"isomorphic-style-loader": "0.0.12",
2525
"jade": "1.11.0",
2626
"jsonwebtoken": "5.7.0",
2727
"markdown-it": "6.0.0",
@@ -40,11 +40,11 @@
4040
"devDependencies": {
4141
"assets-webpack-plugin": "^3.3.0",
4242
"autoprefixer": "^6.3.3",
43-
"babel-cli": "^6.6.0",
43+
"babel-cli": "^6.6.5",
4444
"babel-eslint": "^5.0.0",
45-
"babel-jest": "^9.0.0",
45+
"babel-jest": "^9.0.1",
4646
"babel-loader": "^6.2.4",
47-
"babel-plugin-react-transform": "^2.0.0",
47+
"babel-plugin-react-transform": "^2.0.2",
4848
"babel-plugin-transform-runtime": "^6.6.0",
4949
"babel-preset-es2015": "^6.6.0",
5050
"babel-preset-react": "^6.5.0",
@@ -55,16 +55,16 @@
5555
"csscomb": "^3.1.8",
5656
"del": "^2.2.0",
5757
"enzyme": "^2.0.0",
58-
"eslint": "^2.2.0",
59-
"eslint-config-airbnb": "^6.0.2",
58+
"eslint": "^2.3.0",
59+
"eslint-config-airbnb": "^6.1.0",
6060
"eslint-loader": "^1.3.0",
61-
"eslint-plugin-react": "^4.1.0",
61+
"eslint-plugin-react": "^4.2.0",
6262
"estraverse-fb": "^1.3.1",
6363
"extend": "^3.0.0",
6464
"file-loader": "^0.8.5",
6565
"gaze": "^0.5.2",
6666
"git-repository": "^0.1.1",
67-
"glob": "^7.0.0",
67+
"glob": "^7.0.3",
6868
"jade-loader": "^0.8.0",
6969
"jest-cli": "^0.9.0",
7070
"jscs": "^2.11.0",
@@ -74,17 +74,17 @@
7474
"postcss": "^5.0.19",
7575
"postcss-import": "^8.0.2",
7676
"postcss-loader": "^0.8.1",
77-
"postcss-scss": "^0.1.6",
77+
"postcss-scss": "^0.1.7",
7878
"precss": "^1.4.0",
7979
"raw-loader": "^0.5.1",
8080
"react-addons-test-utils": "^0.14.7",
8181
"react-transform-catch-errors": "^1.0.2",
82-
"react-transform-hmr": "^1.0.2",
82+
"react-transform-hmr": "^1.0.4",
8383
"redbox-react": "^1.2.2",
8484
"replace": "^0.3.0",
8585
"url-loader": "^0.5.7",
8686
"webpack": "^1.12.14",
87-
"webpack-hot-middleware": "^2.9.0",
87+
"webpack-hot-middleware": "^2.9.1",
8888
"webpack-middleware": "^1.5.1"
8989
},
9090
"jest": {

src/components/ContentPage/ContentPage.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ class ContentPage extends Component {
2323
onSetTitle: PropTypes.func.isRequired,
2424
};
2525

26-
render() {
26+
componentWillMount() {
2727
this.context.onSetTitle(this.props.title);
28+
}
29+
30+
render() {
2831
return (
2932
<div className={s.root}>
3033
<div className={s.container}>

src/components/Feedback/Feedback.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,26 @@
77
* LICENSE.txt file in the root directory of this source tree.
88
*/
99

10-
import React, { Component } from 'react';
10+
import React from 'react';
1111
import withStyles from 'isomorphic-style-loader/lib/withStyles';
1212
import s from './Feedback.scss';
1313

14-
class Feedback extends Component {
15-
16-
render() {
17-
return (
18-
<div className={s.root}>
19-
<div className={s.container}>
20-
<a
21-
className={s.link}
22-
href="https://gitter.im/kriasoft/react-starter-kit"
23-
>Ask a question</a>
24-
<span className={s.spacer}>|</span>
25-
<a
26-
className={s.link}
27-
href="https://github.com/kriasoft/react-starter-kit/issues/new"
28-
>Report an issue</a>
29-
</div>
14+
function Feedback() {
15+
return (
16+
<div className={s.root}>
17+
<div className={s.container}>
18+
<a
19+
className={s.link}
20+
href="https://gitter.im/kriasoft/react-starter-kit"
21+
>Ask a question</a>
22+
<span className={s.spacer}>|</span>
23+
<a
24+
className={s.link}
25+
href="https://github.com/kriasoft/react-starter-kit/issues/new"
26+
>Report an issue</a>
3027
</div>
31-
);
32-
}
33-
28+
</div>
29+
);
3430
}
3531

3632
export default withStyles(Feedback, s);

src/components/Footer/Footer.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,25 @@
77
* LICENSE.txt file in the root directory of this source tree.
88
*/
99

10-
import React, { Component } from 'react';
10+
import React from 'react';
1111
import withStyles from 'isomorphic-style-loader/lib/withStyles';
1212
import s from './Footer.scss';
1313
import Link from '../Link';
1414

15-
class Footer extends Component {
16-
17-
render() {
18-
return (
19-
<div className={s.root}>
20-
<div className={s.container}>
21-
<span className={s.text}>© Your Company</span>
22-
<span className={s.spacer}>·</span>
23-
<Link className={s.link} to="/">Home</Link>
24-
<span className={s.spacer}>·</span>
25-
<Link className={s.link} to="/privacy">Privacy</Link>
26-
<span className={s.spacer}>·</span>
27-
<Link className={s.link} to="/not-found">Not Found</Link>
28-
</div>
15+
function Footer() {
16+
return (
17+
<div className={s.root}>
18+
<div className={s.container}>
19+
<span className={s.text}>© Your Company</span>
20+
<span className={s.spacer}>·</span>
21+
<Link className={s.link} to="/">Home</Link>
22+
<span className={s.spacer}>·</span>
23+
<Link className={s.link} to="/privacy">Privacy</Link>
24+
<span className={s.spacer}>·</span>
25+
<Link className={s.link} to="/not-found">Not Found</Link>
2926
</div>
30-
);
31-
}
32-
27+
</div>
28+
);
3329
}
3430

3531
export default withStyles(Footer, s);

src/components/Header/Header.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,28 @@
77
* LICENSE.txt file in the root directory of this source tree.
88
*/
99

10-
import React, { Component } from 'react';
10+
import React from 'react';
1111
import withStyles from 'isomorphic-style-loader/lib/withStyles';
1212
import s from './Header.scss';
1313
import Link from '../Link';
1414
import Navigation from '../Navigation';
1515

16-
class Header extends Component {
17-
18-
render() {
19-
return (
20-
<div className={s.root}>
21-
<div className={s.container}>
22-
<Navigation className={s.nav} />
23-
<Link className={s.brand} to="/">
24-
<img src={require('./logo-small.png')} width="38" height="38" alt="React" />
25-
<span className={s.brandTxt}>Your Company</span>
26-
</Link>
27-
<div className={s.banner}>
28-
<h1 className={s.bannerTitle}>React</h1>
29-
<p className={s.bannerDesc}>Complex web apps made easy</p>
30-
</div>
16+
function Header() {
17+
return (
18+
<div className={s.root}>
19+
<div className={s.container}>
20+
<Navigation className={s.nav} />
21+
<Link className={s.brand} to="/">
22+
<img src={require('./logo-small.png')} width="38" height="38" alt="React" />
23+
<span className={s.brandTxt}>Your Company</span>
24+
</Link>
25+
<div className={s.banner}>
26+
<h1 className={s.bannerTitle}>React</h1>
27+
<p className={s.bannerDesc}>Complex web apps made easy</p>
3128
</div>
3229
</div>
33-
);
34-
}
35-
30+
</div>
31+
);
3632
}
3733

3834
export default withStyles(Header, s);

src/components/Link/Link.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function isModifiedEvent(event) {
1818
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
1919
}
2020

21-
class Link extends Component {
21+
class Link extends Component { // eslint-disable-line react/prefer-stateless-function
2222

2323
static propTypes = {
2424
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
@@ -27,28 +27,29 @@ class Link extends Component {
2727

2828
handleClick = (event) => {
2929
let allowTransition = true;
30-
let clickResult;
3130

32-
if (this.props && this.props.onClick) {
33-
clickResult = this.props.onClick(event);
31+
if (this.props.onClick) {
32+
this.props.onClick(event);
3433
}
3534

3635
if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
3736
return;
3837
}
3938

40-
if (clickResult === false || event.defaultPrevented === true) {
39+
if (event.defaultPrevented === true) {
4140
allowTransition = false;
4241
}
4342

4443
event.preventDefault();
4544

4645
if (allowTransition) {
47-
const link = event.currentTarget;
48-
if (this.props && this.props.to) {
46+
if (this.props.to) {
4947
Location.push(this.props.to);
5048
} else {
51-
Location.push({ pathname: link.pathname, search: link.search });
49+
Location.push({
50+
pathname: event.currentTarget.pathname,
51+
search: event.currentTarget.search,
52+
});
5253
}
5354
}
5455
};

src/components/Navigation/Navigation.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,27 @@
77
* LICENSE.txt file in the root directory of this source tree.
88
*/
99

10-
import React, { Component, PropTypes } from 'react';
10+
import React, { PropTypes } from 'react';
1111
import cx from 'classnames';
1212
import withStyles from 'isomorphic-style-loader/lib/withStyles';
1313
import s from './Navigation.scss';
1414
import Link from '../Link';
1515

16-
class Navigation extends Component {
17-
18-
static propTypes = {
19-
className: PropTypes.string,
20-
};
21-
22-
render() {
23-
return (
24-
<div className={cx(s.root, this.props.className)} role="navigation">
25-
<Link className={s.link} to="/about">About</Link>
26-
<Link className={s.link} to="/contact">Contact</Link>
27-
<span className={s.spacer}> | </span>
28-
<Link className={s.link} to="/login">Log in</Link>
29-
<span className={s.spacer}>or</span>
30-
<Link className={cx(s.link, s.highlight)} to="/register">Sign up</Link>
31-
</div>
32-
);
33-
}
34-
16+
function Navigation({ className }) {
17+
return (
18+
<div className={cx(s.root, className)} role="navigation">
19+
<Link className={s.link} to="/about">About</Link>
20+
<Link className={s.link} to="/contact">Contact</Link>
21+
<span className={s.spacer}> | </span>
22+
<Link className={s.link} to="/login">Log in</Link>
23+
<span className={s.spacer}>or</span>
24+
<Link className={cx(s.link, s.highlight)} to="/register">Sign up</Link>
25+
</div>
26+
);
3527
}
3628

29+
Navigation.propTypes = {
30+
className: PropTypes.string,
31+
};
32+
3733
export default withStyles(Navigation, s);

src/data/queries/news.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,27 @@ const url = 'http://ajax.googleapis.com/ajax/services/feed/load' +
1616
'?v=1.0&num=10&q=https://reactjsnews.com/feed.xml';
1717

1818
let items = [];
19+
let fetching = null;
1920
let lastFetchTime = new Date(1970, 0, 1);
2021

2122
const news = {
2223
type: new List(NewsItemType),
2324
resolve() {
25+
if (fetching) {
26+
return fetching;
27+
}
28+
2429
if ((new Date() - lastFetchTime) > 1000 * 60 * 10 /* 10 mins */) {
2530
lastFetchTime = new Date();
2631
fetch(url)
2732
.then(response => response.json())
2833
.then(data => {
2934
if (data.responseStatus === 200) {
3035
items = data.responseData.feed.entries;
36+
fetching = null;
3137
}
38+
39+
return items;
3240
});
3341
}
3442

0 commit comments

Comments
 (0)