回答編集履歴
1
参考の追加
answer
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
排他制御を実現するのに `ref` を使わないでください。
|
2
2
|
|
3
|
+
[Don’t Overuse Refs - React](https://reactjs.org/docs/refs-and-the-dom.html#dont-overuse-refs)
|
4
|
+
|
3
5
|
[https://codepen.io/og24715/pen/QxoxLq?editors=0010](https://codepen.io/og24715/pen/QxoxLq?editors=0010)
|
4
6
|
|
5
7
|
```js
|
@@ -7,12 +9,14 @@
|
|
7
9
|
state = {
|
8
10
|
selectedButtonId: null,
|
9
11
|
};
|
12
|
+
|
10
13
|
_handleClick = e => {
|
11
14
|
const { id } = e.target;
|
12
15
|
this.setState({
|
13
16
|
selectedButtonId: id,
|
14
17
|
});
|
15
18
|
};
|
19
|
+
|
16
20
|
render() {
|
17
21
|
return (
|
18
22
|
<div>
|