An open API service indexing awesome lists of open source software.

https://github.com/gregnb/simple-react-router

This is a simple client side ONLY React Router
https://github.com/gregnb/simple-react-router

javascript react

Last synced: 3 months ago
JSON representation

This is a simple client side ONLY React Router

Awesome Lists containing this project

README

          

# simple-react-router
This is a simple client side ONLY React Router

Installation
------------
Just download SimpleRouter.min.js (3KB minified) and include it with a script tag like this:
```html

```

Router Configuration
--------------------
The routing configuration is very straight forward. You simply define the paths and tie components to them! Path value of * is used for Index.

Here is the example config that's found in the sample code inside of example/

```html

/* Tie path to Components */
var routing = (

} />
} />
} />

} />
} />


);

/* Structure main app */
var App = (


{routing}

);

/* Render to DOM */
ReactDOM.render(App, document.getElementById('app-root'));

```

The Routing configuration above will render the following:

URL | Component
------------------------|-----------
*/* | **Index**
*/category* | **Category**
*/product* | **Product**
*/support/faqs* | **Support -> FAQs**
*/support/contact* | **Support -> Contact**

How to change Routes
--------------------

To change routing from any place within your app simply call window.router.changeRoute(path). Example usage:

```html

handleClick: function(route, event) {

event.preventDefault();
event.stopPropagation();

window.router.changeRoute('/product');

}

```