Skip to content

Commit ed8cfb8

Browse files
committed
subject 6 to hooks
1 parent 5343813 commit ed8cfb8

File tree

4 files changed

+392
-357
lines changed

4 files changed

+392
-357
lines changed

subjects/06-Controlled-vs-Uncontrolled/exercise.js

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,50 @@ import React from "react";
1919
import ReactDOM from "react-dom";
2020
import serializeForm from "form-serialize";
2121

22-
class CheckoutForm extends React.Component {
23-
render() {
24-
return (
25-
<div>
26-
<h1>Checkout</h1>
27-
<form>
28-
<fieldset>
29-
<legend>Billing Address</legend>
30-
<p>
31-
<label>
32-
Billing Name: <input type="text" />
33-
</label>
34-
</p>
35-
<p>
36-
<label>
37-
Billing State: <input type="text" size="2" />
38-
</label>
39-
</p>
40-
</fieldset>
22+
function CheckoutForm() {
23+
return (
24+
<div>
25+
<h1>Checkout</h1>
26+
<form>
27+
<fieldset>
28+
<legend>Billing Address</legend>
29+
<p>
30+
<label>
31+
Billing Name: <input type="text" />
32+
</label>
33+
</p>
34+
<p>
35+
<label>
36+
Billing State: <input type="text" size="2" />
37+
</label>
38+
</p>
39+
</fieldset>
4140

42-
<br />
41+
<br />
4342

44-
<fieldset>
43+
<fieldset>
44+
<label>
45+
<input type="checkbox" /> Same as billing
46+
</label>
47+
<legend>Shipping Address</legend>
48+
<p>
4549
<label>
46-
<input type="checkbox" /> Same as billing
50+
Shipping Name: <input type="text" />
4751
</label>
48-
<legend>Shipping Address</legend>
49-
<p>
50-
<label>
51-
Shipping Name: <input type="text" />
52-
</label>
53-
</p>
54-
<p>
55-
<label>
56-
Shipping State: <input type="text" size="2" />
57-
</label>
58-
</p>
59-
</fieldset>
60-
52+
</p>
6153
<p>
62-
<button>Submit</button>
54+
<label>
55+
Shipping State: <input type="text" size="2" />
56+
</label>
6357
</p>
64-
</form>
65-
</div>
66-
);
67-
}
58+
</fieldset>
59+
60+
<p>
61+
<button>Submit</button>
62+
</p>
63+
</form>
64+
</div>
65+
);
6866
}
6967

7068
ReactDOM.render(<CheckoutForm />, document.getElementById("app"));

0 commit comments

Comments
 (0)