React Router
Part of flux-react, the router is a simple HTML5 router that will cover most your needs. Read more about FLUX over at Facebook Flux.
Download from dist: ReactRouter.min.js or install from npm with npm install flux-react-router
.
Scope
- Is a function that takes a hash of routes pointing to callbacks
- Alternatively a route can point to another route for redirect
- Go to a route directly with: Routes.goTo(path)
- Return route goTo function with: Routes.deferTo(path), see example
Example
var React = ;var ReactRouter = ;var App = ;var Posts = ;var Post = ; ReactRouter; ReactRouter; ReactRouter; ReactRouter; ReactRouter;// or; /* In other parts of your code */ // Go directly to new routeRouter; // deferTo() returns a function, so that on click it will trigger the route<button onClick=Router
Contribute
Develop
- Run
npm install
- Run
gulp
- Any changes to files in
app/
will be compiled todev/
Test
- Run `gulp test -'./tests/Route-test.js'
- Open the
test.html
file in your browser - Any changes to files in
app/
and the test file will autoreload the browser
Run test in terminal
- Run
npm test
- Currently uses phantomJS, though you can use chrome