IMHO there’s 2 inherit doubts in your question that are worth explaining here. Let me try and describe them, and if I’m over-explaining it please tell me. I’m unaware of your context and knowledge.
The prop styles in rescript-react is an opaque type and it can only be created with ReactDOM.Style.make() and passing the style declarations as labelled arguments + a last argument of unit. This is the implementation made by the react’s bindings, where neither a record or an object would fit in styles since you want a JavaScript Object while Records or Objects in ReScript will eventually convert to a massive JavaScript Object (since all non defined CSS properties will become null fields).
In your case, nothing that I explain matters! Since If I understand it correctly you want to bind to a function where a JS object mimics the style API. In your example, (and here is why I explained all the paragraph above) seems like you only want a few CSS declarations and don’t want ALL declarations.
It’s much easier to bind than any of the approaches above, and you will have safety:
type customStyles = {
width: string
};
type selectStyles = {
container: unit => customStyles
}
This will pass your binding perfectly since React JS expects an object and a record transforms to an object.
I am a beginner in rescript. And i gave not enough info about my question. sorry)
Thanks for all explaining. As I understand, you talk about inline styles.
My problem, that this object will concat with other basic styles inside this component with css-in-js @emotion/css
If i don’t pass provided props, this side component(react-select) overrides other basic styles.
I tried pass rescript object instead Record, but its the same result.
here link to component doc, maybe helps to understand what i mean or where i am wrong.
You can still type the return type by customStyles.container in 2 ways, objects or records. In objects, you would lose the possibility to ensure that keys are safe, while in records you will have that safety but will have to type all the record by hand.