Reputation: 3
I have a simple React form in javascript that I can't seem to get to work. Its extremely simple, but nothing will load to the browser.
import React from 'react';
import { render } from 'react-dom';
function signUp() {
function handle () {console.log(document.getElementById('year').value);
}
return (
<>
<select id="year">
<option>Freshamn</option>
<option>Freshamn</option>
</select>
<div>Name</div>
<input type="text"/>
<div>Email</div>
<input type="text"/>
<div>Password</div>
<input type="text"/>
<div><input type="checkbox"/> Remember me</div>
<button onClick={handle}>Submit</button>
</>
)
};
ReactDOM.render(<signUp/>, document.getElementById("root"));
What am I doing wrong here?
Upvotes: 0
Views: 581
Reputation: 1424
There could be many problems. I would try changing signUp
to SignUp
(change the capitalization). Also, you shouldn't use document.getElementById
. You should give the input a value of a state and use that state value instead.
Upvotes: 1