A basic pushstate router for React with support for asynchronous routing logic, built using react-basic-hooks. I recommend routing-duplex for easy parsing and printing and wire for easy reactive state.
makeRouter ::
forall route f.
Foldable f =>
PushStateInterface ->
{ parse :: String -> f route
, print :: route -> String
, onRoute :: route -> Router route Transitioning Resolved Unit
, onTransition :: Transition route -> Effect Unit
} ->
Effect
{ component :: JSX
, navigate :: route -> Effect Unit
, redirect :: route -> Effect Unit
}
For a basic example see examples/RoutingDuplex.purs
.
Add wire-react-router
to your packages.dhall
:
let additions =
{ wire-react-router =
{ dependencies =
[ "aff"
, "freet"
, "indexed-monad"
, "profunctor-lenses"
, "react-basic-hooks"
, "routing"
]
, repo = "https://github.com/robertdp/purescript-wire-react-router.git"
, version = "v0.2.1"
}
}
And then install with
$ spago install wire-react-router