Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1760

Accessing and tweaking Dom elements (maybe related to type conversion?)

$
0
0

Not sure what you mean here. That you’re not giving it a definition? That means it’s an abstract type that you can’t interact with directly. You have to write bindings to operate on it.

JsxDOMStyle is used in the rescript-react bindings, and the much more common way of interacting with the DOM. Most people will very rarely interact with the DOM directly, which is why the types are so bare bones.

Mutable state is discouraged. Much easier to reason about your code if you avoid mutation. Do you really need it?

The get function is unsound, in two ways. 1) The return type isn’t restricted by anything, and so will be inferred entirely based on how it’s used later. And 2) The return type should be an option, since the property you’re requesting might not be set. Although because of 1) it will be inferred to be an option if that’s how you use it. But it’s highly error-prone. And unnecessary when you have a type where you can access the field directly.


Viewing all articles
Browse latest Browse all 1760

Trending Articles