Module

React.Router.Types

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

#RouteLeaf Source

newtype RouteLeaf arg

Constructors

Instances

#RoutePropsClass Source

class RoutePropsClass props arg | props -> arg 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

Instances

#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 arg => 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

#_id Source

_id :: forall arg props. Route props arg -> String

#_url Source

_url :: forall arg props. Route props arg -> Match arg

#_cls Source

_cls :: forall arg props. RoutePropsClass props arg => (Route props arg) -> (RouteClass props arg)

#IndexRoute Source

data IndexRoute props arg

IndexRoute type The first parameter is the id property.

Constructors

#Router Source

type Router props arg = RoutePropsClass props arg => Cofree List ((Route props arg) /\ (Maybe (IndexRoute props arg)))

Router

router :: Router RouteProps Unit
router =
  Route "main" (unit <$ lit "") mainClass :+
    (Route "home" (unit <$ lit "home") homeClass :+ Nil)
    : (Tuple (Route "user" (unit <$ (lit "user" *> int)) userClass) (Just $ IndexRoute "user-index" userIndexClass) :<
        (Route "book" (unit <$ (lit "books" *> int)) bookClass :+
          (Route "pages" (unit <$ lit "pages") pagesClass :+
            (Route "page" (unit <$ int) pageClass :+ Nil)
            : Nil)
          : Nil)
        : Nil)
    : (Route "user-settings" (unit <$ (lit "user" *> int *> lit "settings")) settingsClass :+ Nil)
    : Nil

#withoutIndex Source

withoutIndex :: forall arg props. RoutePropsClass props arg => Route props arg -> List (Cofree List ((Route props arg) /\ (Maybe (IndexRoute props arg)))) -> Cofree List ((Route props arg) /\ (Maybe (IndexRoute props arg)))

#(:+) Source

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

:+ lets define routes without index route

#RouterConfig Source

newtype RouterConfig

Constructors

Instances