ReScript seems to be a better way to write JS code, but I am not able to find what should be a simple single line of docs.
How do I call functions like document.createElement()
?
I tried Js.document, Dom.document, by looking at this page: https://rescript-lang.org/docs/manual/latest/api, but that code gives an error in the playground:
The value
document
can't be found in Js
The valuedocument
can't be found in Dom
Since re-script is powered by React (JSX) and not standard ECMA JavaScript, I do not think you can use calls like
document.createElement
.Instead, you should create the element via:
This transpiles into the following:
I modified the default Playground script: