-
Your task is to create a simple login form component in React.
-
The form should consist of two fields: one for
username
and one forpassword
. Each input should update itsvalue
attribute on input change. -
The
onSubmit
handler is passed through the props to the component and accepts two parameters:username
andpassword
(in that order). -
When the Submit button is clicked,
onSubmit
handler should be called. Use a button click event handler for this purpose. -
The application uses React 16.13.1.
-
Requirements:
-
Create an
input
element for theusername
field. It should have itsid
set tousername-input
andtype
attribute set totext
. -
The
username
input should update itsvalue
attribute on being changed with the entered username. -
Create an
input
element for thepassword
field. It should have itsid
set topassword-input
andtype
attribute set topassword
. -
The
password
input should update itsvalue
attribute on being changed with the entered password. -
Create a Submit button with its
id
set tologin-button
. -
The Submit button should be disabled(
disabled
attribute set totrue
) until bothusername
andpassword
fields are filled. -
The
onSubmit
handler should be called when the Submit button is clicked. -
The
onSubmit
handler should be called withusername
andpassword
passed as parameters.
-
-
The styling and layout of the components is not assessed. Place them within the main
div
in the provided starting code. Wrapping inputs and the Submit button in theform
element is not needed. -
Make sure the login form component is a default export.
import React from "react";
// Use functional or class component based on your preference.
// Make it a default export.
export default function LoginForm({ onSubmit }) {
return (<div>
Place your components here
</div>);
}