Skip to content

Commit 0ae791b

Browse files
committed
Small tweaks
1 parent 7157491 commit 0ae791b

File tree

12 files changed

+54
-55
lines changed

12 files changed

+54
-55
lines changed

examples/animations/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { Router, Route, Link } from 'react-router';
44

55
var { CSSTransitionGroup } = React.addons;
66

7-
var history = createHistory();
8-
97
var App = React.createClass({
108
render() {
119
var key = this.props.location.pathname;
@@ -17,7 +15,7 @@ var App = React.createClass({
1715
<li><Link to="/page2">Page 2</Link></li>
1816
</ul>
1917
<CSSTransitionGroup component="div" transitionName="example">
20-
{React.cloneElement(this.props.children || <div/>, { key: key })}
18+
{React.cloneElement(this.props.children || <div />, { key: key })}
2119
</CSSTransitionGroup>
2220
</div>
2321
);
@@ -46,6 +44,8 @@ var Page2 = React.createClass({
4644
}
4745
});
4846

47+
var history = createHistory();
48+
4949
React.render((
5050
<Router history={history}>
5151
<Route path="/" component={App}>

examples/async-data/app.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import { Router, Route, Link, Navigation } from 'react-router';
44
import { loadContacts, loadContact, createContact } from './utils';
55
import AsyncProps from 'react-router/lib/experimental/AsyncProps';
66

7-
var history = createHistory();
8-
97
var Spinner = React.createClass({
108
render() {
119
return (
1210
<div style={{textAlign: 'center', padding: 50}}>
13-
<img src="spinner.gif" width="64" height="64"/>
11+
<img src="spinner.gif" width="64" height="64" />
1412
</div>
1513
);
1614
}
@@ -52,7 +50,7 @@ var App = React.createClass({
5250
return (
5351
<div className="App" style={appStyle}>
5452
<form onSubmit={this.handleSubmit}>
55-
<input placeholder="First name"/> <input placeholder="Last name"/>{' '}
53+
<input placeholder="First name" /> <input placeholder="Last name" />{' '}
5654
<button type="submit">submit</button>
5755
</form>
5856
<div style={{display: 'flex'}}>
@@ -91,7 +89,7 @@ var Contact = React.createClass({
9189
<div style={{opacity: this.props.loadingAsyncProps ? 0.5 : 1}}>
9290
<p><Link to="/">Back</Link></p>
9391
<h1>{contact.first} {contact.last}</h1>
94-
<p><img key={contact.avatar} src={contact.avatar} height="200"/></p>
92+
<p><img key={contact.avatar} src={contact.avatar} height="200" /></p>
9593
</div>
9694
);
9795
}
@@ -107,12 +105,14 @@ var Index = React.createClass({
107105
}
108106
});
109107

108+
var history = createHistory();
109+
110110
React.render((
111111
<Router history={history} createElement={AsyncProps.createElement}>
112-
<Route component={AsyncProps} renderInitialLoad={() => <Spinner/> }>
112+
<Route component={AsyncProps} renderInitialLoad={() => <Spinner /> }>
113113
<Route component={App}>
114-
<Route path="/" component={Index}/>
115-
<Route path="contact/:id" component={Contact}/>
114+
<Route path="/" component={Index} />
115+
<Route path="contact/:id" component={Contact} />
116116
</Route>
117117
</Route>
118118
</Router>

examples/auth-flow/app.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import createHistory from 'history/lib/createHashHistory';
33
import { Router, Route, Link, Navigation } from 'react-router';
44
import auth from './auth';
55

6-
var history = createHistory();
7-
86
var App = React.createClass({
97
getInitialState() {
108
return {
@@ -89,8 +87,8 @@ var Login = React.createClass({
8987
render() {
9088
return (
9189
<form onSubmit={this.handleSubmit}>
92-
<label><input ref="email" placeholder="email" defaultValue="[email protected]"/></label>
93-
<label><input ref="pass" placeholder="password"/></label> (hint: password1)<br/>
90+
<label><input ref="email" placeholder="email" defaultValue="[email protected]" /></label>
91+
<label><input ref="pass" placeholder="password" /></label> (hint: password1)<br />
9492
<button type="submit">login</button>
9593
{this.state.error && (
9694
<p>Bad login information</p>
@@ -121,13 +119,15 @@ function requireAuth(nextState, redirectTo) {
121119
redirectTo('/login', null, { nextPathname: nextState.location.pathname });
122120
}
123121

122+
var history = createHistory();
123+
124124
React.render((
125125
<Router history={history}>
126126
<Route path="/" component={App}>
127-
<Route path="login" component={Login}/>
128-
<Route path="logout" component={Logout}/>
129-
<Route path="about" component={About}/>
130-
<Route path="dashboard" component={Dashboard} onEnter={requireAuth}/>
127+
<Route path="login" component={Login} />
128+
<Route path="logout" component={Logout} />
129+
<Route path="about" component={About} />
130+
<Route path="dashboard" component={Dashboard} onEnter={requireAuth} />
131131
</Route>
132132
</Router>
133133
), document.getElementById('example'));

examples/dynamic-segments/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import React from 'react';
22
import createHistory from 'history/lib/createHashHistory';
33
import { Router, Route, Link, Redirect } from 'react-router';
44

5-
var history = createHistory();
6-
75
var App = React.createClass({
86
render() {
97
return (
@@ -48,6 +46,8 @@ var Task = React.createClass({
4846
}
4947
});
5048

49+
var history = createHistory();
50+
5151
React.render((
5252
<Router history={history}>
5353
<Route path="/" component={App}>

examples/huge-apps/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { Router } from 'react-router';
44
import AsyncProps from 'react-router/lib/experimental/AsyncProps';
55
import stubbedCourses from './stubs/COURSES';
66

7-
var history = createHistory();
8-
97
var rootRoute = {
108
component: AsyncProps,
119

@@ -27,6 +25,8 @@ var rootRoute = {
2725
]
2826
};
2927

28+
var history = createHistory();
29+
3030
React.render((
3131
<Router
3232
history={history}

examples/master-detail/app.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ var Contact = React.createClass({
106106
var avatar = contact.avatar || 'http://placecage.com/50/50';
107107
return (
108108
<div className="Contact">
109-
<img height="50" src={avatar} key={avatar}/>
109+
<img height="50" src={avatar} key={avatar} />
110110
<h3>{name}</h3>
111111
<button onClick={this.destroy}>Delete</button>
112112
</div>
@@ -132,8 +132,8 @@ var NewContact = React.createClass({
132132
return (
133133
<form onSubmit={this.createContact}>
134134
<p>
135-
<input type="text" ref="first" placeholder="First name"/>
136-
<input type="text" ref="last" placeholder="Last name"/>
135+
<input type="text" ref="first" placeholder="First name" />
136+
<input type="text" ref="last" placeholder="Last name" />
137137
</p>
138138
<p>
139139
<button type="submit">Save</button> <Link to="/">Cancel</Link>
@@ -154,10 +154,10 @@ var history = createHistory();
154154
React.render((
155155
<Router history={history}>
156156
<Route component={App}>
157-
<Route path="/" component={Index}/>
158-
<Route path="contact/new" component={NewContact}/>
159-
<Route path="contact/:id" component={Contact}/>
160-
<Route path="*" component={NotFound}/>
157+
<Route path="/" component={Index} />
158+
<Route path="contact/new" component={NewContact} />
159+
<Route path="contact/:id" component={Contact} />
160+
<Route path="*" component={NotFound} />
161161
</Route>
162162
</Router>
163163
), document.getElementById('example'));

examples/passing-props-to-children/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import React from 'react';
22
import createHistory from 'history/lib/createHashHistory';
33
import { Router, Route, Link, Navigation } from 'react-router';
44

5-
var history = createHistory();
6-
75
var App = React.createClass({
86
mixins: [ Navigation ],
97

@@ -71,10 +69,12 @@ var Taco = React.createClass({
7169
}
7270
});
7371

72+
var history = createHistory();
73+
7474
React.render((
7575
<Router history={history}>
7676
<Route path="/" component={App}>
77-
<Route path="taco/:name" component={Taco}/>
77+
<Route path="taco/:name" component={Taco} />
7878
</Route>
7979
</Router>
8080
), document.getElementById('example'));

examples/pinterest/app.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import React from 'react';
22
import createHistory from 'history/lib/createHashHistory';
33
import { Router, Link } from 'react-router';
44

5-
var history = createHistory();
6-
75
var pictures = [
86
{ id: 0, src: 'http://placekitten.com/601/601' },
97
{ id: 1, src: 'http://placekitten.com/610/610' },
@@ -73,7 +71,7 @@ var FeedPicture = React.createClass({
7371
<h2>Inside the feed</h2>
7472
<Link to="/">back</Link>
7573
<p>
76-
<img src={pictures[this.props.params.id].src} height="400"/>
74+
<img src={pictures[this.props.params.id].src} height="400" />
7775
</p>
7876
</div>
7977
);
@@ -87,7 +85,7 @@ var Picture = React.createClass({
8785
<h2>Not Inside the feed</h2>
8886
<Link to="/">Feed</Link>
8987
<p>
90-
<img src={pictures[this.props.params.id].src}/>
88+
<img src={pictures[this.props.params.id].src} />
9189
</p>
9290
</div>
9391
);
@@ -125,6 +123,8 @@ var RootRoute = {
125123
}
126124
};
127125

126+
var history = createHistory();
127+
128128
React.render(
129129
<Router history={history} children={RootRoute} />,
130130
document.getElementById('example')
@@ -158,4 +158,3 @@ React.render(
158158
// 9. `App -> PictureRoute` renders
159159
//
160160
// 10. I am very glad there aren't ten steps to explain this ...
161-
//

examples/query-params/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import React from 'react';
22
import createHistory from 'history/lib/createHashHistory';
33
import { Router, Route, Link } from 'react-router';
44

5-
var history = createHistory();
6-
75
var User = React.createClass({
86
render() {
97
var { query } = this.props.location;
@@ -33,10 +31,12 @@ var App = React.createClass({
3331
}
3432
});
3533

34+
var history = createHistory();
35+
3636
React.render((
3737
<Router history={history}>
3838
<Route path="/" component={App}>
39-
<Route path="user/:userID" component={User}/>
39+
<Route path="user/:userID" component={User} />
4040
</Route>
4141
</Router>
4242
), document.getElementById('example'));

examples/shared-root/app.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import React from 'react';
22
import createHistory from 'history/lib/createHashHistory';
33
import { Router, Route, Link } from 'react-router';
44

5-
var history = createHistory();
6-
75
var App = React.createClass({
86
render() {
97
return (
@@ -71,15 +69,17 @@ var ForgotPassword = React.createClass({
7169
}
7270
});
7371

72+
var history = createHistory();
73+
7474
React.render((
7575
<Router history={history}>
7676
<Route path="/" component={App}>
7777
<Route component={SignedOut}>
78-
<Route path="signin" component={SignIn}/>
79-
<Route path="forgot-password" component={ForgotPassword}/>
78+
<Route path="signin" component={SignIn} />
79+
<Route path="forgot-password" component={ForgotPassword} />
8080
</Route>
8181
<Route component={SignedIn}>
82-
<Route path="home" component={Home}/>
82+
<Route path="home" component={Home} />
8383
</Route>
8484
</Route>
8585
</Router>

0 commit comments

Comments
 (0)