Skip to content

Commit bcdfcb0

Browse files
author
Ari
committed
Updates
1 parent e8b1574 commit bcdfcb0

File tree

7 files changed

+102
-99
lines changed

7 files changed

+102
-99
lines changed

Diff for: day-10/post.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ class Panel extends React.Component {
564564
componentDidMount() {this.updateData();}
565565
componentWillReceiveProps(nextProps) {
566566
// Check to see if the requestRefresh prop has changed
567-
if (nextProps.requestRefresh !== this.props.requestRefresh) {
567+
if (nextProps.requestRefresh === true) {
568568
this.setState({loading: true}, this.updateData);
569569
}
570570
}

Diff for: day-10/src/Content.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
const data = require('./data.json')
2+
const data = require('./data.json');
33
import ActivityItem from './components/Timeline/GithubActivityItem';
44

55
class Content extends React.Component {
@@ -9,7 +9,7 @@ class Content extends React.Component {
99
this.state = {
1010
loading: false, // <~ set loading to false
1111
activities: this.props.activities
12-
}
12+
};
1313
}
1414

1515
// Update the data when the component mounts
@@ -19,37 +19,37 @@ class Content extends React.Component {
1919

2020
componentWillReceiveProps(nextProps) {
2121
// Check to see if the requestRefresh prop has changed
22-
if (nextProps.requestRefresh !== this.props.requestRefresh) {
22+
if (nextProps.requestRefresh === true) {
2323
this.setState({loading: true}, this.updateData);
2424
}
2525
}
2626

2727
// Call out to github data and refresh directory
2828
updateData() {
29-
this.setState({
30-
loading: false,
31-
activities: this.state.activities
32-
}, this.props.onComponentRefresh);
29+
this.setState(
30+
{
31+
loading: false,
32+
activities: this.state.activities
33+
},
34+
this.props.onComponentRefresh
35+
);
3336
}
3437

3538
render() {
3639
const {loading, activities} = this.state;
37-
40+
3841
return (
3942
<div className="content">
40-
<div className="line"></div>
43+
<div className="line" />
4144
{/* Show loading message if loading */}
4245
{loading && <div>Loading</div>}
4346
{/* Timeline item */}
44-
{activities.map((activity) => (
45-
<ActivityItem
46-
key={activity.id}
47-
activity={activity} />
47+
{activities.map(activity => (
48+
<ActivityItem key={activity.id} activity={activity} />
4849
))}
49-
5050
</div>
51-
)
51+
);
5252
}
5353
}
5454

55-
export default Content
55+
export default Content;

Diff for: day-10/src/ContentSearch.js

+29-28
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22

33
import Header from './HeaderSearch';
4-
import ActivityItem from './components/Timeline/GithubActivityItem'
4+
import ActivityItem from './components/Timeline/GithubActivityItem';
55

6-
const data = require('./data.json')
6+
const data = require('./data.json');
77

88
class Panel extends React.Component {
99
constructor(props) {
@@ -12,14 +12,16 @@ class Panel extends React.Component {
1212
this.state = {
1313
loading: false, // <~ set loading to false
1414
activities: data,
15-
filtered: data,
16-
}
15+
filtered: data
16+
};
1717
}
1818

19-
componentDidMount() {this.updateData();}
19+
componentDidMount() {
20+
this.updateData();
21+
}
2022
componentWillReceiveProps(nextProps) {
2123
// Check to see if the requestRefresh prop has changed
22-
if (nextProps.requestRefresh !== this.props.requestRefresh) {
24+
if (nextProps.requestRefresh === true) {
2325
this.setState({loading: true}, this.updateData);
2426
}
2527
}
@@ -28,48 +30,47 @@ class Panel extends React.Component {
2830
if (txt === '') {
2931
this.setState({
3032
filtered: this.state.activities
31-
})
33+
});
3234
} else {
33-
const { activities } = this.state
34-
const filtered = activities.filter(a => a.actor && a.actor.login.match(txt))
35+
const {activities} = this.state;
36+
const filtered = activities.filter(
37+
a => a.actor && a.actor.login.match(txt)
38+
);
3539
this.setState({
3640
filtered
37-
})
41+
});
3842
}
39-
}
43+
};
4044

4145
// Call out to github and refresh directory
4246
updateData() {
43-
this.setState({
44-
loading: false,
45-
activities: data
46-
}, this.props.onComponentRefresh);
47+
this.setState(
48+
{
49+
loading: false,
50+
activities: data
51+
},
52+
this.props.onComponentRefresh
53+
);
4754
}
4855

4956
render() {
5057
const {loading, filtered} = this.state;
51-
58+
5259
return (
5360
<div>
54-
<Header
55-
onSubmit={this.handleSearch}
56-
title="Github activity" />
61+
<Header onSubmit={this.handleSearch} title="Github activity" />
5762
<div className="content">
58-
<div className="line"></div>
63+
<div className="line" />
5964
{/* Show loading message if loading */}
6065
{loading && <div>Loading</div>}
6166
{/* Timeline item */}
62-
{filtered.map((activity) => (
63-
<ActivityItem
64-
key={activity.id}
65-
activity={activity} />
67+
{filtered.map(activity => (
68+
<ActivityItem key={activity.id} activity={activity} />
6669
))}
67-
6870
</div>
6971
</div>
70-
)
72+
);
7173
}
7274
}
7375

74-
75-
export default Panel
76+
export default Panel;

Diff for: day-10/src/WorkingSearch.js

+23-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React from 'react'
2-
import 'whatwg-fetch'
1+
import React from 'react';
2+
import 'whatwg-fetch';
33

44
import Header from './components/Timeline/Header';
55
import AsyncContent from './ContentSearch';
66

7-
import data from './data.json'
7+
import data from './data.json';
88
// const rootUrl = `https://api.github.com`
99
// const endpoint = `/users/fullstackreact/events`
1010

@@ -16,7 +16,7 @@ class SearchableContent extends React.Component {
1616
loading: false, // <~ set loading to false
1717
activities: [],
1818
searchFilter: ''
19-
}
19+
};
2020
}
2121

2222
// Update the data when the component mounts
@@ -26,7 +26,7 @@ class SearchableContent extends React.Component {
2626

2727
componentWillReceiveProps(nextProps) {
2828
// Check to see if the requestRefresh prop has changed
29-
if (nextProps.requestRefresh !== this.props.requestRefresh) {
29+
if (nextProps.requestRefresh === true) {
3030
this.setState({loading: true}, this.updateData);
3131
}
3232
}
@@ -35,50 +35,53 @@ class SearchableContent extends React.Component {
3535
this.setState({
3636
searchFilter: val,
3737
loading: true
38-
})
38+
});
3939
}
4040

4141
onComponentRefresh() {
42-
this.setState({loading: false})
42+
this.setState({loading: false});
4343
}
4444

4545
// Call out to github and refresh directory
4646
updateData() {
4747
const {activities, searchFilter} = this.state;
4848

49-
const filter = searchFilter !== '' &&
50-
(e => e.actor.login.match(new RegExp(searchFilter)));
49+
const filter =
50+
searchFilter !== '' &&
51+
(e => e.actor.login.match(new RegExp(searchFilter)));
5152

52-
const fetchDataOrCache = () => Promise.resolve(activities)
53+
const fetchDataOrCache = () => Promise.resolve(activities);
5354

5455
// Use cached data if we have it
5556
return fetchDataOrCache()
5657
.then(json => json || data)
57-
.then(json => filter ? json.filter(filter) : json)
58+
.then(json => (filter ? json.filter(filter) : json))
5859
.then(json => {
5960
if (activities.length === 0) {
60-
this.setState({activities: json})
61+
this.setState({activities: json});
6162
}
6263
return json;
6364
})
64-
.then(json => json.slice(0, 4))
65+
.then(json => json.slice(0, 4));
6566
}
6667

6768
render() {
6869
const {loading} = this.state;
69-
70+
7071
return (
7172
<div className="notificationsFrame">
7273
<Header
73-
onSearch={this.handleSearch.bind(this)}
74-
title="Github activity" />
75-
<AsyncContent
74+
onSearch={this.handleSearch.bind(this)}
75+
title="Github activity"
76+
/>
77+
<AsyncContent
7678
requestRefresh={loading}
7779
onComponentRefresh={this.onComponentRefresh.bind(this)}
78-
fetchData={this.updateData.bind(this)} />
80+
fetchData={this.updateData.bind(this)}
81+
/>
7982
</div>
80-
)
83+
);
8184
}
8285
}
8386

84-
export default SearchableContent
87+
export default SearchableContent;

Diff for: day-7/post.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class Content extends React.Component {
178178
// ...
179179
componentWillReceiveProps(nextProps) {
180180
// Check to see if the requestRefresh prop has changed
181-
if (nextProps.requestRefresh !== this.props.requestRefresh) {
181+
if (nextProps.requestRefresh === true) {
182182
this.setState({loading: true}, this.updateData);
183183
}
184184
}

Diff for: day-7/src/Content2.js

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
const data = require('./data.json').slice(0, 4)
3+
const data = require('./data.json').slice(0, 4);
44
import ActivityItem from './components/Timeline/GithubActivityItem';
55

66
class Content extends React.Component {
@@ -10,7 +10,7 @@ class Content extends React.Component {
1010
this.state = {
1111
loading: false, // <~ set loading to false
1212
activities: []
13-
}
13+
};
1414
}
1515

1616
componentDidMount() {
@@ -19,38 +19,37 @@ class Content extends React.Component {
1919

2020
componentWillReceiveProps(nextProps) {
2121
// Check to see if the requestRefresh prop has changed
22-
if (nextProps.requestRefresh !== this.props.requestRefresh) {
22+
if (nextProps.requestRefresh === true) {
2323
this.setState({loading: true}, this.updateData);
2424
}
2525
}
2626

2727
// Call out to github data and refresh directory
2828
updateData() {
29-
this.setState({
30-
loading: false,
31-
activities: data
32-
.sort(() => 0.5 - Math.random()).slice(0, 4)
33-
}, this.props.onComponentRefresh);
29+
this.setState(
30+
{
31+
loading: false,
32+
activities: data.sort(() => 0.5 - Math.random()).slice(0, 4)
33+
},
34+
this.props.onComponentRefresh
35+
);
3436
}
3537

3638
render() {
3739
const {loading, activities} = this.state;
38-
40+
3941
return (
4042
<div className="content">
41-
<div className="line"></div>
43+
<div className="line" />
4244
{/* Show loading message if loading */}
4345
{loading && <div>Loading</div>}
4446
{/* Timeline item */}
45-
{activities.map((activity) => (
46-
<ActivityItem
47-
key={activity.id}
48-
activity={activity} />
47+
{activities.map(activity => (
48+
<ActivityItem key={activity.id} activity={activity} />
4949
))}
50-
5150
</div>
52-
)
51+
);
5352
}
5453
}
5554

56-
export default Content
55+
export default Content;

0 commit comments

Comments
 (0)