davide
11/08/2017, 11:47 PMFilipp Riabchun
11/10/2017, 4:15 PM@JsModule("react-bootstrap/lib/Alert")
external val Alert: RClass<dynamic>
// then somewhere in your components
Alert {
attrs {
bsStyle = "warning"
}
+"Got an error"
}
Which roughly corresponds to this JSX:
<Alert bsStyle = "warning">Got an error</Alert>
Filipp Riabchun
11/10/2017, 4:18 PMdynamic
with some props spec based on propTypes or documentation (https://react-bootstrap.github.io/components.html#alerts)
external interface AlertProps: RProps {
var bsClass: string
var bsStyle: string
var closeLabel: string
var onDismiss: () => Unit
}
@JsModule("react-bootstrap/lib/Alert")
external val Alert: RClass<AlertProps>
Then if you try to do something like this, you'll get type errors at compile time
Alert {
attrs {
bsStyle = 100 // invalid value
foo = true // invalid property
}
}
davide
11/13/2017, 8:14 AMdavide
11/19/2017, 5:51 PMsrc/contact/ContactList.kt:46:21: error: unresolved reference: bsStyle
bsStyle = “warning”
My project was created with create-react-kotlin-appdavide
11/20/2017, 6:48 AM