Kotlin wrapper for React Router DOM library
npm install @jetbrains/kotlin-react-router-domKotlin wrapper for React Router DOM library.
Major version number of this wrapper matches that of React Router DOM itself.
Both BrowserRouter and HashRouter are supported.
1. npm i @jetbrains/kotlin-react-router-dom
2. npm run gen-idea-libs
See the Bintray page for Maven and Gradle
installation instructions.
``kotlin
interface IdProps : RProps {
var id: Int
}
class RootComponent : RComponent
override fun RBuilder.render() {
hashRouter { // or "browserRouter"
switch {
route("/", IndexComponent::class, exact = true)
route("/login", strict = true) {
login(providers = listOf("plain", "facebook"))
a(href = "#/") {
+"Back"
}
}
route
div {
+"User id: ${props.match.params.id}"
}
}
redirect(from = "/redirect", to = "/redirected")
}
}
}
}
``
See lawik123/kotlin-poc-frontend-react-redux.
This project is an implementation/translation of the react-redux Todo List example project in Kotlin (with the addition of react-router).