Giter Site home page Giter Site logo

modulexcite / react-router-component Goto Github PK

View Code? Open in Web Editor NEW

This project forked from strml/react-router-component

0.0 1.0 0.0 1.6 MB

Declarative router component for React.

Home Page: http://strml.viewdocs.io/react-router-component

License: MIT License

Makefile 1.18% JavaScript 98.82%

react-router-component's Introduction

React Router Component

Version Compatibility
> 0.24 React 0.13
> 0.23 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>

Alternatively, if you don't prefer JSX:

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

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

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

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

Compatibility

Compatible with React 0.12 and React 0.13. Older versions work with older versions of React, see the commit log.

Docs

react-router-component's People

Contributors

abersager avatar andreypopp avatar banyan avatar brendanmoore avatar chollier avatar dvemac avatar fgnass avatar jed avatar jsg2021 avatar mattatcha avatar matthewwithanm avatar megamaddu avatar mikew avatar mitchelkuijpers avatar parshap avatar robertfw avatar simenbrekken avatar strml avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.