Skip to content

Instantly share code, notes, and snippets.

@mathieu-anderson
Last active September 1, 2019 12:40
Show Gist options
  • Save mathieu-anderson/4d88e8894320723a3adc59ffca055835 to your computer and use it in GitHub Desktop.
Save mathieu-anderson/4d88e8894320723a3adc59ffca055835 to your computer and use it in GitHub Desktop.
Vanilla JS input
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