Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for BrowserRouter #42

Merged
merged 1 commit into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion kotlin-react-router-dom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Kotlin wrapper for [React Router DOM library](https://reacttraining.com/react-router/).
Major version number of this wrapper matches that of React Router DOM itself.

Only hash routing is supported for now.
Both BrowserRouter and HashRouter are supported.

### Installation

Expand Down Expand Up @@ -40,3 +40,10 @@ class RootComponent : RComponent<RProps, RState>() {
}
}
```

For **BrowserRouter** just exchange hashRouter with:
```kotlin
browserRouter {
//routing code ...
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ external class HashRouterComponent : Component<RProps, RState> {
override fun render(): ReactElement?
}

@JsName("BrowserRouter")
external class BrowserRouterComponent : Component<RProps, RState> {
override fun render(): ReactElement?
}

@JsName("Switch")
external class SwitchComponent : Component<RProps, RState> {
override fun render(): ReactElement?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import kotlin.reflect.KClass

fun RBuilder.hashRouter(handler: RHandler<RProps>) = child(HashRouterComponent::class, handler)

fun RBuilder.browserRouter(handler: RHandler<RProps>) = child(BrowserRouterComponent::class, handler)

fun RBuilder.switch(handler: RHandler<RProps>) = child(SwitchComponent::class, handler)

fun RBuilder.route(
Expand Down