Skip to content

Commit 50ca45f

Browse files
committed
updates
1 parent e6db10a commit 50ca45f

File tree

4 files changed

+65
-27
lines changed

4 files changed

+65
-27
lines changed

.eslintrc.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"extends": "eslint:recommended",
7+
"parserOptions": {
8+
"ecmaFeatures": {
9+
"experimentalObjectRestSpread": true,
10+
"jsx": true
11+
},
12+
"sourceType": "module"
13+
},
14+
"plugins": [
15+
"react"
16+
],
17+
"rules": {
18+
"linebreak-style": [
19+
"error",
20+
"unix"
21+
],
22+
"quotes": [
23+
"error",
24+
"single"
25+
],
26+
"semi": [
27+
"error",
28+
"always"
29+
]
30+
}
31+
}

basic-react-components/4.2.md

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ String, naming the component, used in debugging messages. If using JSX this is s
2525
Callback function invoked once immediately before the initial rendering occurs
2626
***
2727
[`componentDidMount`](http://facebook.github.io/react/docs/component-specs.html#mounting-componentdidmount) :
28-
Callback function immediately after the initial rendering occurs
28+
Callback function invoked immediately after the initial rendering occurs
2929
***
3030
[`componentWillReceiveProps`](http://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops) :
3131
Callback function invoked when a component is receiving new props
@@ -43,33 +43,9 @@ Callback function invoked immediately after the component's updates are flushed
4343
Callback function invoked immediately before a component is unmounted from the DOM
4444
***
4545

46-
An example of creating a React component with both state and props is shown below.
47-
48-
```
49-
var Timer = React.createClass({
50-
getInitialState: function() {
51-
return {secondsElapsed: Number(this.props.startTime) || 0};
52-
},
53-
tick: function() {
54-
this.setState({secondsElapsed: this.state.secondsElapsed + 1});
55-
},
56-
componentDidMount: function() {
57-
this.interval = setInterval(this.tick, 1000);
58-
},
59-
componentWillUnmount: function() {
60-
clearInterval(this.interval);
61-
},
62-
render: function() {
63-
return (
64-
<div>Seconds Elapsed: {this.state.secondsElapsed}</div>
65-
);
66-
}
67-
});
68-
69-
ReactDOM.render(<Timer startTime="60" />, app);
70-
```
71-
46+
An example of creating a React component, using `React.createClass()`, with both state and props is shown below.
7247

48+
[source code](https://jsfiddle.net/12u58fjb/#tabs=js,result,html,resources)
7349

7450
#### Notes
7551

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
},
1818
"homepage": "https://github.com/FrontendMasters/react-enlightenment#readme",
1919
"devDependencies": {
20+
"eslint": "^2.7.0",
21+
"eslint-config-standard": "^5.1.0",
22+
"eslint-plugin-promise": "^1.1.0",
23+
"eslint-plugin-react": "^4.3.0",
24+
"eslint-plugin-standard": "^1.3.2",
2025
"gitbook-plugin-jsfiddle": "^1.0.0"
2126
}
2227
}

test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var Timer = React.createClass({
2+
getInitialState: function() {
3+
return {
4+
secondsElapsed: Number(this.props.startTime) || 0
5+
};
6+
},
7+
tick: function() {
8+
this.setState({
9+
secondsElapsed: this.state.secondsElapsed + 1
10+
});
11+
},
12+
componentDidMount: function() {
13+
this.interval = setInterval(this.tick, 1000);
14+
},
15+
componentWillUnmount: function() {
16+
clearInterval(this.interval);
17+
},
18+
render: function() {
19+
return (
20+
<div>
21+
Seconds Elapsed: {this.state.secondsElapsed}
22+
</div>
23+
);
24+
}
25+
});
26+
ReactDOM.render(< Timer startTime = "60" / >, app);

0 commit comments

Comments
 (0)