Skip to content

Commit

Permalink
Merge pull request #42 from LittleLightCz/browserRouterSupport
Browse files Browse the repository at this point in the history
Added support for BrowserRouter
  • Loading branch information
Leonya committed Mar 26, 2018
2 parents d05761c + 715d12f commit ad46441
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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

0 comments on commit ad46441

Please sign in to comment.