Module

React.Router.Types

Package
purescript-cofree-react-router
Repository
coot/purescript-cofree-react-router

#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.

#Route Source

data Route props arg

Route type The first parameter is an identifier.

Constructors

Instances

#IndexRoute Source

data IndexRoute props arg

IndexRoute type The first parameter is the id property.

Constructors

#urlLens Source

urlLens :: forall arg props. RoutePropsClass props => Lens' (Route props arg) (Match arg)

#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 :+ []
            ]
        ]

#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)))

#(:+) Source

Operator alias for React.Router.Types.withoutIndex (right-associative / precedence 6)

:+ lets define routes without index route