From f15c051d14dcd9dde200392dab6aa2c27eb2deb7 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Wed, 5 Aug 2015 21:35:34 +0800 Subject: [PATCH] Update --- react-router.md | 112 ++++++++++++++++++++++++++++++++++++++++++++++++ unicode.md | 1 + 2 files changed, 113 insertions(+) create mode 100644 react-router.md diff --git a/react-router.md b/react-router.md new file mode 100644 index 000000000..7240bf2e2 --- /dev/null +++ b/react-router.md @@ -0,0 +1,112 @@ +--- +title: React-router +--- + +### Basic + +```js +import { default as Router, Route } from 'react-router' + +const routes = ( + + + +) + +Router.run(routes, Router.HashLocation, (Root) => { + React.render(, document.getElementById('all')) +}) +``` + +### Nesting + +```js +const routes = ( + + + + + +) + +import { RouteHandler } from 'react-router' + +const Chrome = React.createClass({ + render () { + return ( +
+

App

+ +
+ ) + } +}) +``` + +### URL params + +```js +var Message = React.createClass({ + componentDidMount: function () { + // from the path `/inbox/messages/:id` + var id = this.props.params.id + ... +``` + +### Link + +```js +import { Link } from 'react-router' + + + + + + +``` + +### Other config + +```js + + + + + + + + + +``` + +### Router.create + +```js +var router = Router.create({ + routes: ..., + location: Router.HistoryLocation +}) + +router.run((Root) => { ... }) +``` + +### Navigation + +```js +import { Navigation } from 'react-router' + +React.createClass({ + mixins: [ Navigation ], ... +}) + +this + .transitionTo('user', {id: 10}) + .transitionTo('/path') + .transitionTo('http://...') + .replaceWith('about') + .makePath('about') // return URL + .makeHref('about') // return URL + .goBack() +``` diff --git a/unicode.md b/unicode.md index 95a048fc7..7bc37c271 100644 --- a/unicode.md +++ b/unicode.md @@ -9,6 +9,7 @@ layout: default ☯ \u262f yinyang ♞ \u265e horse ☀ \u2600 rays + ⚠ \u26a0 warning ★ star ☆ star2