MCPcopy Index your code
hub / github.com/STRML/react-router-component

github.com/STRML/react-router-component @v0.40.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.40.0 ↗ · + Follow
84 symbols 129 edges 33 files 9 documented · 11%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

React Router Component

TravisCI Build Status

Version Compatibility
>= 0.39.0 React v15,16
>= 0.32.0 React v15
>= 0.27.0 React 0.14
0.24 - 0.26.0 React 0.13
0.23 - 0.26.0 React 0.12
0.20 - 0.22.2 React 0.11
< 0.20 React 0.10

React router component allows you to define routes in your React application in a declarative manner, directly as a part of your component hierarchy.

Project Overview

Usage is as simple as just returning a configured router component from your component's render() method:

<Locations>
  <Location path="/" handler={MainPage} />
  <Location path="/users/:username" handler={UserPage} />
  <Location path="/search/*" handler={SearchPage} />
  <Location path={/\/product\/([0-9]*)/} handler={ProductPage} />
</Locations>

Having routes defined as a part of your component hierarchy allows to dynamically reconfigure routing based on your application state. For example you can return a different set of allowed locations for anonymous and signed-in users.

React router component can dispatch based on location.pathname or location.hash if browser doesn't support History API (see hash routing).

Props can be passed through the router by setting them directly on each <Location>, or to all possible routes via a childProps hash.

Furthermore it provides advanced features like support for regex matching, full page server side rendering, multiple routers on the same page, querystring parsing, and contextual routers.

Its functionality is tested using Saucelabs on all modern browsers (IE >= 9, Chrome >= 27, Firefox >= 25, Safari >= 6 and Mobile Safari on iPhone and iPad >= 6).

Its size is about 3.5kb gzipped.

Installation

React router component is packaged on npm:

% npm install react-router-component

Docs

Core symbols most depended-on inside this repo

assertRendered
called by 87
tests/browser/browser.js
delay
called by 20
tests/browser/browser.js
clickOn
called by 20
tests/browser/browser.js
matchRoutes
called by 13
lib/matchRoutes.js
setUp
called by 6
tests/browser/browser.js
assertNotNavigated
called by 4
tests/browser/browser.js
invariant
called by 3
lib/util/invariant.js
assertRendered
called by 3
tests/browser/browser-jsx.jsx

Shape

Function 41
Class 27
Method 16

Languages

TypeScript100%

Modules by API surface

tests/server/server.js32 symbols
examples/es6/app.js11 symbols
tests/browser/browser.js8 symbols
tests/browser/browser-jsx.js6 symbols
tests/browser/browser-jsx.jsx5 symbols
tests/unit/RouterMixin.js2 symbols
lib/matchRoutes.js2 symbols
lib/environment/QuerystringKeyEnvironment.js2 symbols
lib/environment/LocalStorageKeyEnvironment.js2 symbols
lib/environment/Environment.js2 symbols
lib/environment/DummyEnvironment.js2 symbols
lib/RouterMixin.js2 symbols

For agents

$ claude mcp add react-router-component \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact