WebComp
  • Introduction
  • Lifecycle Methods
  • Rendering From String
  • Handling User Input
  • Flags
  • Events
  • Context
  • Shadow DOM
  • Routing
Powered by GitBook
On this page

Was this helpful?

Handling User Input

Since WebComp components' architecture is virtually the same as React's, you can handle interactions in the similar way:

class SuperInput extends WebComponent {
  handleChange = (e) => {
    this.setState({
      email: e.target.value,
    });
  }

  render() {
    return <input name="email" onInput={this.handleChange} />;
  }
}

Linked State

WebComp also provides convenient linkState method on a component which you can use to manage simple inputs:

class SuperInput extends WebComponent {
  render() {
    return <input name="email" onInput={this.linkState('email')} />;
  }
}

Optionally, you can provide a second path argument to explicitly provide a dot-notated path to the new state value for more custom bindings.

PreviousRendering From StringNextFlags

Last updated 6 years ago

Was this helpful?