Last active
September 1, 2019 12:40
-
-
Save mathieu-anderson/4d88e8894320723a3adc59ffca055835 to your computer and use it in GitHub Desktop.
Vanilla JS input
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 * as React from "react"; | |
import { render } from "react-dom"; | |
// Vanilla JS | |
function JsInput({ value, label }) { | |
return ( | |
<div className="container"> | |
<div className="label">{label}</div> | |
<div className="typeof"> | |
Type: <b>{typeof value}</b> | |
</div> | |
<input value={value} /> | |
</div> | |
); | |
} | |
function App() { | |
return ( | |
<div className="App"> | |
<JsInput value={1} label="Vanilla JS (not typesafe)" /> | |
// You can do this and get [object Object] in your field without any error | |
// <JsInput value={{value: 1}} label="Vanilla JS (not typesafe)" /> | |
</div> | |
); | |
} | |
const rootElement = document.getElementById("root"); | |
render(<App />, rootElement); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment