cherrytree-for-react
Advanced tools
Comparing version 1.0.1 to 1.1.1
{ | ||
"name": "cherrytree-for-react", | ||
"version": "1.0.1", | ||
"version": "1.1.1", | ||
"description": "An adapter for cherrytree router for using it with React", | ||
@@ -13,5 +13,2 @@ "main": "./lib/cherrytreeForReact", | ||
"license": "ISC", | ||
"peerDependencies": { | ||
"react": "^0.13.3" | ||
}, | ||
"devDependencies": { | ||
@@ -18,0 +15,0 @@ "babel": "^5.8.21", |
@@ -7,3 +7,3 @@ # cherrytree-for-react | ||
$ npm install --save cherrytree cherrytree-for-react | ||
$ npm install --save react cherrytree cherrytree-for-react | ||
@@ -17,6 +17,2 @@ ```js | ||
import { Provider } from 'redux/react' | ||
import { createDispatcher, createRedux, composeStores } from 'redux' | ||
import * as stores from './stores' | ||
const { | ||
@@ -30,22 +26,8 @@ Application, | ||
const redux = createRedux(createDispatcher(composeStores(stores))) | ||
const cherrytree = createCherrytree().map(routes) | ||
const cherrytree = createCherrytree() | ||
.map(routes) | ||
.use(function redirect (transition) { | ||
transition.routes.map(route => { | ||
if (route.options.redirect) | ||
cherrytree.replaceWith.apply(cherrytree, route.options.redirect) | ||
}) | ||
}) | ||
.use(function error (transition) { | ||
transition.catch(err => console.error(err.stack)) | ||
}) | ||
export default class App extends React.Component { | ||
render () { | ||
return ( | ||
<Provider redux={redux}> | ||
{() => <Router router={cherrytree} />} | ||
</Provider> | ||
<Router router={cherrytree} /> | ||
) | ||
@@ -62,3 +44,2 @@ } | ||
}) | ||
route('index', { path: '', redirect: [ 'user', { username: 'KidkArolis' }] }) | ||
}) | ||
@@ -68,4 +49,2 @@ } | ||
Note: this example demonstrates how you'd use `cherrytree-for-react` with `redux`. If you don't use `redux`, simply use `Router` component at the top level, instead of the `Provider`. | ||
The router will be injected into the context of the render tree. You can use it to generate links or initiate transitions, e.g. | ||
@@ -72,0 +51,0 @@ |
0
9414
109