Skip to content

Commit 05d795e

Browse files
davidnguyen11jaredpalmer
authored andcommitted
added example razzle + react router 3 (#539)
* added example razzle + react router 3 * Remove yarn.lock * Fix pkg.json
1 parent db7b28b commit 05d795e

File tree

15 files changed

+297
-0
lines changed

15 files changed

+297
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
logs
2+
*.log
3+
npm-debug.log*
4+
.DS_Store
5+
6+
coverage
7+
node_modules
8+
build
9+
.env.local
10+
.env.development.local
11+
.env.test.local
12+
.env.production.local
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Razzle x React Router 3
2+
3+
## How to use
4+
Download the example [or clone the whole project](https://github.com/jaredpalmer/razzle.git):
5+
6+
```bash
7+
curl https://codeload.github.com/jaredpalmer/razzle/tar.gz/master | tar -xz --strip=2 razzle-master/examples/with-react-router-3
8+
cd with-react-router-3
9+
```
10+
11+
Install it and run:
12+
13+
```bash
14+
yarn install
15+
yarn start
16+
```
17+
18+
## Idea behind the example
19+
This is a basic, bare-bones example of how to use Razzle and React Router 3.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "razzle-examples-with-react-router-3",
3+
"version": "0.1.0",
4+
"license": "MIT",
5+
"scripts": {
6+
"start": "razzle start",
7+
"build": "razzle build",
8+
"test": "razzle test --env=jsdom",
9+
"prestart:prod": "razzle build",
10+
"start:prod": "NODE_ENV=production node build/server.js"
11+
},
12+
"dependencies": {
13+
"express": "^4.16.2",
14+
"prop-types": "^15.6.1",
15+
"razzle": "^0.8.12",
16+
"react": "^16.2.0",
17+
"react-dom": "^16.2.0",
18+
"react-router": "^3.2.0",
19+
"react-router-redux": "4.0.8",
20+
"react-router-scroll": "0.4.2"
21+
}
22+
}
32.2 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
import { Link } from 'react-router';
3+
import App from './App';
4+
import './Home.css';
5+
6+
class About extends React.Component {
7+
render() {
8+
return (
9+
<App>
10+
<div className="Home">
11+
<div className="Home-header">
12+
<h2>About page</h2>
13+
</div>
14+
<p>
15+
<Link to="home">Home</Link>
16+
</p>
17+
</div>
18+
</App>
19+
);
20+
}
21+
}
22+
23+
export default About;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
body {
2+
margin: 0;
3+
padding: 0;
4+
font-family: sans-serif;
5+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import './App.css';
3+
4+
class App extends React.Component {
5+
render() {
6+
return <div>{this.props.children}</div>;
7+
}
8+
}
9+
10+
export default App;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.Home {
2+
text-align: center;
3+
}
4+
5+
.Home-logo {
6+
animation: Home-logo-spin infinite 20s linear;
7+
height: 80px;
8+
}
9+
10+
.Home-header {
11+
background-color: #222;
12+
height: 150px;
13+
padding: 20px;
14+
color: white;
15+
}
16+
17+
.Home-intro {
18+
font-size: large;
19+
}
20+
21+
.Home-resources {
22+
list-style: none;
23+
}
24+
25+
.Home-resources > li {
26+
display: inline-block;
27+
padding: 1rem;
28+
}
29+
30+
@keyframes Home-logo-spin {
31+
from {
32+
transform: rotate(0deg);
33+
}
34+
to {
35+
transform: rotate(360deg);
36+
}
37+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
import { Link } from 'react-router';
3+
import logo from './react.svg';
4+
import App from './App';
5+
import './Home.css';
6+
7+
class Home extends React.Component {
8+
render() {
9+
return (
10+
<App>
11+
<div className="Home">
12+
<div className="Home-header">
13+
<img src={logo} className="Home-logo" alt="logo" />
14+
<h2>Welcome to Razzle</h2>
15+
</div>
16+
<p className="Home-intro">
17+
To get started, edit <code>src/App.js</code> or{' '}
18+
<code>src/Home.js</code> and save to reload.
19+
</p>
20+
<p>
21+
<Link to="about">About</Link>
22+
</p>
23+
<ul className="Home-resources">
24+
<li>
25+
<a href="https://github.com/jaredpalmer/razzle">Docs</a>
26+
</li>
27+
<li>
28+
<a href="https://github.com/jaredpalmer/razzle/issues">Issues</a>
29+
</li>
30+
<li>
31+
<a href="https://palmer.chat">Community Slack</a>
32+
</li>
33+
</ul>
34+
</div>
35+
</App>
36+
);
37+
}
38+
}
39+
40+
export default Home;

0 commit comments

Comments
 (0)