ReScript-Playground
HTML
<div id="app"></div>
JavaScript
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as React from "https://esm.sh/[email protected]";
import * as JsxRuntime from "https://esm.sh/[email protected]/jsx-runtime";
import * as Client from 'https://esm.sh/[email protected]/client';
// If your code uses some rescript-runtime code, import @rescript/std as well, e.g.
import * as Curry from "https://cdn.skypack.dev/@rescript/[email protected]/lib/es6/curry.js";
function Playground$CounterMessage(props) {
var username = props.username;
var count = props.count;
var times = count !== 1 ? (
count !== 2 ? String(count) + " times" : "twice"
) : "once";
var name = username !== undefined && username !== "" ? username : "Anonymous";
return JsxRuntime.jsx("div", {
children: "Hello " + name + ", you clicked me " + times
});
}
var CounterMessage = {
make: Playground$CounterMessage
};
function Playground$App(props) {
var match = React.useState(function () {
return 0;
});
var setCount = match[1];
var match$1 = React.useState(function () {
return "Anonymous";
});
var setUsername = match$1[1];
var username = match$1[0];
return JsxRuntime.jsxs("div", {
children: [
"Username: ",
JsxRuntime.jsx("input", {
type: "text",
value: username,
onChange: (function (evt) {
evt.preventDefault();
var username = evt.target.value;
Curry._1(setUsername, (function (_prev) {
return username;
}));
})
}),
JsxRuntime.jsx("button", {
children: "Click me",
onClick: (function (_evt) {
Curry._1(setCount, (function (prev) {
return prev + 1 | 0;
...