React SPA Framework - Router - Methods

This section describes the methods used to manipulate the application's navigation routing.

format(obj)

Formats an object to a URI.

Parameters:
obj:

Object

An object whose fields represent routing parameters.

Return Value:

String

A URI generated from the specified object using the registered routing rules.

Formatting is performed using the rule registered using the register method. If several routing rules are registered, they are evaluated in the order of registration. If the specified object fits a rule, the rule is used to generate a URI. Otherwise, the remaining routing rules are evaluated by one another.

parse(uri)

Decodes the specified URI to an object using the registered routing rules.

Parameters:
uri:

String

The URI to be parsed.

Return Value:

Object

An object whose fields represent routing parameters. The field values are set to the parameter values extracted from the specified URI.

Parsing is performed using the rule registered using the register method. If several routing rules are registered, they are evaluated in the order of registration. If the specified URI fits a rule, the rule is used to process the URL. Otherwise, the remaining routing rules are evaluated one by another.

register(pattern, defaults, constraints)

Adds a routing rule to the list of registered rules.

Parameters:
pattern:

String

Specifies the parameters a URL must contain in order to be processed by the rule.

defaults:

Object

| undefined

An object whose field names correspond to the pattern parameters. These fields are set to the parameters' default values.

constraints:

Object

| undefined

An object whose field names correspond to the pattern parameters. These fields are set to the parameters' constraint expressions.

Use this method to register a routing rule in an application. Call this method after instantiating the HtmlApplication object.

For details of possible variants of rule patterns, defaults and constraints, refer to the Declare a Routing topic.