// Generated by ReScript, PLEASE EDIT WITH CARE
import * as Curry from "./stdlib/curry.js";
import * as React from "react";
import * as JsxRuntime from "react/jsx-runtime";
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;
}));
})
}),
JsxRuntime.jsx("button", {
children: "Reset",
onClick: (function (_evt) {
Curry._1(setCount, (function (param) {
return 0;
}));
})
}),
JsxRuntime.jsx(Playground$CounterMessage, {
count: match[0],
username: username
})
]
});
}
var App = {
make: Playground$App
};
export {
CounterMessage ,
App ,
}
/* react Not a pure module */
ReScript Version
Syntax
Module-System
Enabled Libraries
- @rescript/react
Warning Flags
+a-4-9-20-40-41-42-50-61-102
Compiled successfully