Last active
October 7, 2015 14:26
-
-
Save gon250/52f62bc153f8e4e42fa3 to your computer and use it in GitHub Desktop.
Basic settings for react-router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Module dependencies | |
*/ | |
import React from 'react'; | |
import { Router, Route, Link } from 'react-router' | |
class App extends React.Component { | |
render(){ | |
return <div> | |
<h1>App</h1> | |
<ul> | |
<li><Link to="/user">User</Link></li> | |
<li><Link to="/about">about</Link></li> | |
</ul> | |
{this.props.children} | |
</div> | |
} | |
} | |
class About extends React.Component{ | |
render(){ | |
return <p>You are in About View</p> | |
} | |
} | |
class User extends React.Component{ | |
render(){ | |
return <p>You are in User View</p> | |
} | |
} | |
let routes = <Router> | |
<Route path="/" component={App}> | |
<Route path="about" component={About} /> | |
<Route path="user" component={User} /> | |
</Route> | |
</Router> | |
React.render(routes, document.getElementById('container')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "example-route-react", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"author": "gon250", | |
"license": "ISC", | |
"dependencies": { | |
"babelify": "^6.3.0", | |
"browserify": "^11.2.0", | |
"react": "^0.13.3", | |
"react-router": "^1.0.0-rc1" | |
}, | |
"scripts": { | |
"build": "browserify -t babelify app.js > build.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment