我正在尝试在我的create-react-kotlin-app中使用这个库:
我想生成一堆类型安全的包装器。我是这样开始的:
@file:JsModule("material-ui")
package material
import react.RState
import react.React
import react.ReactElement
external class Typography : React.Component<dynamic, RState> {
override fun render(): ReactElement
}
...
fun RBuilder.typography(
classes: String = "",
variant: Variant = Variant.body1,
align: Align = Align.inherit,
color: Color = Color.default,
gutterBottom: Boolean = false,
noWrap: Boolean = false,
paragraph: Boolean = false,
handler: RHandler<dynamic>
) = child(Typography::class) {
attrs {
this.className = classes
this.align = align.name
this.color = color.name
this.variant = variant.name
this.gutterBottom = gutterBottom
this.noWrap = noWrap
this.paragraph = paragraph
}
handler()
}
并像这样使用它:
typography(variant = Variant.title, color = Color.inherit) {
+"Hello World"
}
这是正确的方法吗?