rescript-lang:master ← dkirchhof:split-domprops
opened 08:21AM - 09 Jan 26 UTC
While building custom jsx transformers or defining bindings for "jsx-libraries" …other than react, it could be possible, that some "fields" in domProps has other types as in the core library.
Examples:
- it uses "class" instead of "className"
- style is a string instead of an object
- events are named "click" or "onclick" instead of "onClick"
- ...
So, if you want to add a field, fine. Just extend domProps.
But if you want to change an existing field, you have to create your own type and copy hundreds of existing fields. This is tedious.
---
I splitted the domProps into some subtypes, so it is easier to define your own domProps.
Example:
```res
type customJsxProps = {
children?: child, // custom type for children
class?: string, // class instead of className
}
type customDomProps = {
...customJsxProps,
...JsxDOM.baseProps,
...JsxDOM.events,
...JsxDOM.svg,
style?: string, // string instead of JsxDOMStyle.t
}
```
---
What do you think?
Is there an easier way?
Does it have performance implications?