Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form Controls for JSX #89

Open
2 tasks
thescientist13 opened this issue Aug 10, 2022 · 0 comments
Open
2 tasks

Form Controls for JSX #89

thescientist13 opened this issue Aug 10, 2022 · 0 comments
Labels
expirement feature New feature or request JSX

Comments

@thescientist13
Copy link
Member

Type of Change

  • New Feature Request

Summary

Would like to support these kinds of features

  1. Boolean Attributes
  2. Form Submission

Details

Boolean Attributes

Like a checked attribute

render() {
  const { completed, task } = this.todo;
  const checked = completed ? 'checked' : '';

  return (
    <input class="complete-todo" type="checkbox" checked/>
  );
}

To my knowledge, JSX does not support this syntax

<input type="checkbox" {isChecked} />

Form Submission

Would like be able to do something like this

class Todo extends HTMLElement {
  addTodo(e) {
    e.preventDefault();
    ...

    this.render();
  }

  render() {
    return 
      <form onsubmit={this.addTodo}>
        <input class="todo-input" type="text" placeholder="Food Shopping" required/>
        <button class="add-todo" type="button" onclick={this.addTodo}>+ Add</button>
      </form>
    );
  }
}

Right now it works, but by accident I think, and seeing this error in the console
Screen Shot 2022-08-02 at 3 30 58 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expirement feature New feature or request JSX
Projects
None yet
Development

No branches or pull requests

1 participant