Listing 3-1: A React Component
import React from "react";
function Login(){
const handleSubmit = (e) => {
e.preventDefault();
console.log('logging in ' + e.target[0].value);
// do something else here
}
return (
<form id="login-form" onSubmit={handleSubmit}>
<input type="email"
id="email"
placeholder="E-Mail Address" />
<input type="password"
id="password" />
<button>Login</button>
</form>
);
}
export default Login;
Download the examples, report issues, and ask/answer questions in the discussion area by visiting the book's github page. All of the code for the book is also available on codesandbox.io for you to play around with.
ReactJS Foundations is published by John Wiley and Sons, Inc and is available in paperback and eBook.