Rocon Website

ReactRouteRecord

type ReactRouteRecord<Match>

Object that represents one route defined by route builders. A route represented by ReactRouteRecord<Match> requires a match object of type Match.

record.action

action: ((match: Match) => ReactElement | null) | undefined

Action registered to this route. An action is a function that receives a match object and returns a React element.

record.attach

attach: AttachFunction<ActionResult, Match>

Attaches another route builder to this route and returns that builder.

Example

// Create a Path route builder which defines /foo.
const fooRoutesBuilder = Rocon.Path()
  .route("foo");
// Get the route record for /foo.
const fooRoute: ReactRouteRecord<{}> = fooRoutesBuilder._.foo;

// Attach a Search route builder to define a route for /foo?key=value.
const anotherBuilder = fooRoute.attach(Rocon.Search("key")); 
const fooRoute2: ReactRouteRecord<{ key: string }> =
  anotherBuilder.route;