Closed olivercoad closed 4 years ago
Trying to get path mode working but router.onUrlChanged always passes the hash value.
router.onUrlChanged
Here is code to replicate on Feliz.Router 3.0.0
Router.currentPath() returns the expected value but router.onUrlChanged passes the hash mode segments to the callback funtion.
Router.currentPath()
module App open Elmish open Elmish.React open Feliz open Feliz.Router let parseUrl segments = let currentPath = Router.currentPath() sprintf "%A" currentPath, sprintf "%A" segments type Msg = | UrlChanged of string * string let init() = parseUrl <| Router.currentPath() let update msg state = match msg with | UrlChanged (currentPath, currentUrl) -> currentPath, currentUrl let render (currentPath: string, currentUrl: string) (dispatch: Msg -> unit) = React.router [ router.pathMode router.onUrlChanged (parseUrl >> UrlChanged >> dispatch) router.children [ Html.h1 "Router.currentPath(): " Html.p currentPath Html.h1 "segments from router.onUrlChanged: " Html.p currentUrl Html.a [ prop.onClick (fun _ -> Router.navigatePath "/foo#bar") prop.children [ Html.p "change path" ] ] ] ] #if DEBUG printfn "Enabled HMR" open Elmish.HMR #endif Program.mkSimple init update render |> Program.withReactSynchronous "elmish-app" |> Program.run
Hi @olivercoad, thanks a lot for filing the issue! It seems like I haven't tested the new API properly, sorry about that. It should now be fixed as of v3.0.1 :smile:
Trying to get path mode working but
router.onUrlChanged
always passes the hash value.Here is code to replicate on Feliz.Router 3.0.0
Router.currentPath()
returns the expected value but router.onUrlChanged passes the hash mode segments to the callback funtion.