Upon using a third-party API that provides built-in JSX components and their corresponding attributes.
For example.
For the above example, I used:
bs.module("@airtable/blocks/ui") external text: React.element = “Text”
However, in the provided API, there is a custom attribute named “textColor” that takes a string.
I am not sure how this can be done as the Rescript compiler does not take in any custom attribute.
If I didn’t completely misunderstand, Text is just a React component. So you need to bind to it like you bind to any React component. Maybe something like this?
/* Wrap into Text module for clarity */
module Text = {
@react.component @bs.module
"@airtable/blocks/ui"
external make: (~textColor: option<string>=?) => React.element = "Text"
}
/* how to use */
<Text textColor="light" />
But personally I’d go a bit further and try to improve the type safety of the textColor like this: