React.Router
- Package
- purescript-cofree-react-router
- Repository
- coot/purescript-cofree-react-router
Re-exports from React.Router.Class
#RoutePropsClass Source
class RoutePropsClass props where
The RoutePropsClass
type class let one extend the properties passed to
each RouteClass
react class component. There is one instance
RouteProps
defined in the React.Router.Type
module.
The mkProps
member function receives the name of the route and an
nonempty array of args read from the url. You can use
React.Router.Utils.last
function to get the last element of the array
with arguments obtained from the corrsponding url part.
Members
Re-exports from React.Router.Components
#link' Source
link' :: String -> Array ReactElement -> ReactElement
as link
, but with empty properties passed to the underlying a
element.
#link Source
link :: LinkProps -> Array ReactElement -> ReactElement
link
element; use it instead of a
to route the user through application.
#browserRouterClass Source
browserRouterClass :: forall notfound args props. RoutePropsClass props => ReactClass (RouterProps props args notfound)
React class for the browerRouter
element. Use it to init your application.
router = ... :: Router _
main = void $ elm >>= render (createElement browserRouterClass {router, notFound: Nothing} [])
where
elm = do
elm_ <- window >>= document >>= getElementById (ElementId "app") <<< documentToNonElementParentNode <<< htmlDocumentToDocument
pure $ unsafePartial fromJust (toMaybe elm_)
```
#browserRouter Source
browserRouter :: forall notfound args props eff. RoutePropsClass props => ReactSpec (RouterProps props args notfound) RouterState (dom :: DOM, history :: HISTORY | eff)
ReactSpec
for the browserRouterClass
- the main entry point react
class for the router.
Re-exports from React.Router.Routing
#runRouter Source
runRouter :: forall args props. RoutePropsClass props => String -> Cofree Array (Tuple (Route props args) (Maybe (IndexRoute props args))) -> Maybe ReactElement
Main entry point for running Router
, it returns ReactElement
that can
be injected into React vDOM.
#matchRouter Source
matchRouter :: forall args props. RoutePropsClass props => Route -> Router props args -> Maybe (Cofree Array { indexRoute :: Maybe (IndexRoute props args), props :: props args, route :: Route props args, url :: Route })
Re-exports from React.Router.Types
#Router Source
type Router props arg = RoutePropsClass props => Cofree Array (Tuple (Route props arg) (Maybe (IndexRoute props arg)))
Router
router =
Route "home" "/" Home :+
[ Route "user" "user/:id" User :+
[ Route "email" "email" UserEmail :+ []
, Route "password" "password" UserPassword :+ []
]
, Tuple (Route "books" "books" Books) (Just BooksIndex) :<
[ Route "book" ":id" Book :+ []
, Route "reader" "reader" BookReader :+ []
]
]
#RouteProps Source
newtype RouteProps arg
RouteProps
type keeps track route related data: id, currently matched
argument and array of arguments - if the route is nested this will hold
list of all parent arguments.
Constructors
Instances
#RouteClass Source
type RouteClass props arg = RoutePropsClass props => ReactClass (props arg)
React component which will be mounted at matching node It recieves array of all matching routes.
#IndexRoute Source
data IndexRoute props arg
IndexRoute type The first parameter is the id property.
Constructors
IndexRoute String (RouteClass props arg)
#withoutIndex Source
withoutIndex :: forall arg props. RoutePropsClass props => Route props arg -> Array (Cofree Array (Tuple (Route props arg) (Maybe (IndexRoute props arg)))) -> Cofree Array (Tuple (Route props arg) (Maybe (IndexRoute props arg)))