HTML copied into a component rarely works as it is. Fix every JSX rule this form breaks.
What to build
A sign-up form converted from HTML to valid JSX.
Requirements
- The form keeps its structure: an
h2Join the club, alabelfor the inputemail(connected withhtmlFor), aninputwith the idemailand the typeemail, abr, alabelfornewsand a checkboxnews, and abuttonwith the classprimary. - The heading keeps its style: font size 20 pixels and the colour
#1C3028(as a style object). - Everything is returned as one element.
Constraints
Do not remove any element; fix the JSX instead.
Example
The preview shows the heading, the email field with its label, the checkbox with its label, and the button.
Why it works
JSX is JavaScript, so HTML's class and for become className and htmlFor, inline styles become objects, every element must be closed, and one root element is returned.
Hints
Hint 1
class becomes className, for becomes htmlFor, and every tag must be closed: <input ... />.
Hint 2
The inline style becomes an object with camelCase names; a component returns one element.
Solution
Show one correct solution (try it yourself first)
export default function App() {
return (
<form>
<h2 style={{ fontSize: 20, color: "#1C3028" }}>Join the club</h2>
<label htmlFor="email">Email</label>
<input id="email" type="email" />
<br />
<label htmlFor="news">Send me news</label>
<input id="news" type="checkbox" />
<button className="primary">Join</button>
</form>
);
}