Поле ввода OnEnter React React

 <input
     onKeyPress={(e) => {
          if (e.key === "Enter") {
              this.setState({ message: e.target.value },
                () => {
                        alert(this.state.message);
                       });
              }
      }}
   type="text"
 />
tinydev