@@ -12,11 +12,11 @@ import { FaMinus, FaPlus } from "react-icons/fa"
12
12
// In practical terms, an uncontrolled component is one whose value is changed
13
13
// exclusively by the *user interacting with it*.
14
14
//
15
- // You can still set the initial state of an uncontrolled component with
15
+ // You can still set the initial state of an uncontrolled component with
16
16
// defaultValue (and defaultChecked).
17
17
//
18
18
// A controlled component is one that does not own its state, but rather its
19
- // state is controlled by the component that rendered it.
19
+ // state is controlled by the component that rendered it.
20
20
//
21
21
// In practical terms it means the state is controlled exclusively by the
22
22
// *programmer*.
@@ -25,7 +25,7 @@ import { FaMinus, FaPlus } from "react-icons/fa"
25
25
// value of an input by some other means than the user interacting with it.
26
26
//
27
27
// If you need the value of a component in your state, but you don't ever set
28
- // the value of the component with anything other thant he user interacting
28
+ // the value of the component with anything other than the user interacting
29
29
// with it, you can use either controlled or uncontrolled, it's the same. We
30
30
// prefer uncontrolled in these situations just to communicate intent.
31
31
@@ -37,23 +37,13 @@ export default function Minutes({ date }) {
37
37
return (
38
38
< div className = "Minutes" >
39
39
< div >
40
- < button
41
- type = "button"
42
- className = "icon_button Minutes_button"
43
- >
40
+ < button type = "button" className = "icon_button Minutes_button" >
44
41
< FaMinus />
45
42
</ button >
46
43
</ div >
47
- < input
48
- className = "Minutes_input"
49
- defaultValue = { 0 }
50
- id = "minutes"
51
- />
44
+ < input className = "Minutes_input" defaultValue = { 0 } id = "minutes" />
52
45
< div >
53
- < button
54
- type = "button"
55
- className = "icon_button Minutes_button"
56
- >
46
+ < button type = "button" className = "icon_button Minutes_button" >
57
47
< FaPlus />
58
48
</ button >
59
49
</ div >
@@ -64,7 +54,6 @@ export default function Minutes({ date }) {
64
54
)
65
55
}
66
56
67
-
68
57
/******************************************************************************/
69
58
// We want these two buttons to change the value of the input, but it doesn't
70
59
// work when we use defaultValue, we need to use value.
@@ -112,8 +101,6 @@ export default function Minutes({ date }) {
112
101
// )
113
102
// }
114
103
115
-
116
-
117
104
/******************************************************************************/
118
105
// But when we use defaultValue then the user can't type into the input
119
106
// anymore. Why does that make sense? React eliminates time. It's declarative.
@@ -297,7 +284,6 @@ export default function Minutes({ date }) {
297
284
// }
298
285
// }
299
286
300
-
301
287
// return (
302
288
// <div className="Minutes">
303
289
// <div>
@@ -332,4 +318,3 @@ export default function Minutes({ date }) {
332
318
// </div>
333
319
// )
334
320
// }
335
-
0 commit comments