回答編集履歴
1
Typo
answer
CHANGED
@@ -4,12 +4,12 @@
|
|
4
4
|
|
5
5
|
[State and Lifecycle - React](https://reactjs.org/docs/state-and-lifecycle.html)
|
6
6
|
|
7
|
-
|
7
|
+
componentで何らかの外部のイベントをリッスンしたいときは、ライフサイクルメソッドの[componentDidMount](https://reactjs.org/docs/react-component.html#componentdidmount)でリスナーを設定し、[componentWillUnmount](https://reactjs.org/docs/react-component.html#componentwillunmount)で解除するようにするのが普通です。
|
8
8
|
|
9
|
-
```
|
9
|
+
```jsx
|
10
10
|
ReactDOM.render( < NewTab / > , document.getElementById('root'));
|
11
11
|
|
12
|
-
class
|
12
|
+
class NewTab extends React.Component {
|
13
13
|
constructor(props) {
|
14
14
|
super(props);
|
15
15
|
this.state = {
|