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.

Last updated