Skip to content

Why in the LoginForm we need the (expensive?) onChange method? #7

@ghost

Description

Can I ask you why in the LoginForm.js we need the onChange method and why we can't get data from the form onSubmit?

I think it's really expensive to update the state everytime a user change an input, isn't it?

https://github.com/Remchi/bookworm-react/blob/master/src/components/forms/LoginForm.js#L17-L20

Can't we do something like this instead?

onSubmit = e => {
    this.setState({
      data: { email: document.getElementById("email").value, password: document.getElementById("password").value }
    });
}

Maybe something more beautiful...?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions