The problem
We can type component props explicitly via a type props and
external make: React.component<props> = "SomeComponent"
This pattern is already used by most of the components here.
It enables record type spreads which are useful when we want to copy all props for our own component and add additional ones.
module Modal = {
type props = {
...ReactNative.Modal.props,
className?: string,
}
// maybe there is a better way to do this. My usecase is nativewind and this works.
let make: React.component<props> = Obj.magic(ReactNative.Modal.make)
}
Without the prop type ReactNative.Modal.make would expect a generic parameter for all labeled arguments of the function, which is hard to type and error prone.
Considered solution
adjust components like Modal.res to use this pattern to define their props.
The problem
We can type component props explicitly via a
type propsandThis pattern is already used by most of the components here.
It enables record type spreads which are useful when we want to copy all props for our own component and add additional ones.
Without the prop type
ReactNative.Modal.makewould expect a generic parameter for all labeled arguments of the function, which is hard to type and error prone.Considered solution
adjust components like
Modal.resto use this pattern to define their props.