Last active
January 27, 2019 22:02
-
-
Save a7ul/5c2bf589617fff0149268a2dfb03ef8d to your computer and use it in GitHub Desktop.
react-webcomponentify-examples-my-input.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { registerAsWebComponent } from "react-webcomponentify"; | |
export class Input extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { buttonText: "" }; | |
this.onInputEnter = this.onInputEnter.bind(this); | |
} | |
onInputEnter(evt) { | |
this.setState({ | |
buttonText: evt.target.value | |
}); | |
} | |
render() { | |
return ( | |
<div> | |
<input | |
style="width:200px;height:40px;padding:10px;font-size:14px;border:2px solid blue;" | |
type="text" | |
placeholder="enter some text here" | |
onChange={this.onInputEnter} | |
/> | |
<br /> | |
<br /> | |
<code>Value of this.state.buttonText: </code> | |
{this.state.buttonText} | |
</div> | |
); | |
} | |
} | |
registerAsWebComponent(Input, "my-input"); | |
/* | |
In html: | |
<my-input></my-input> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment