@@ -4,13 +4,11 @@ import { Router, Route, Link, Navigation } from 'react-router';
4
4
import { loadContacts , loadContact , createContact } from './utils' ;
5
5
import AsyncProps from 'react-router/lib/experimental/AsyncProps' ;
6
6
7
- var history = createHistory ( ) ;
8
-
9
7
var Spinner = React . createClass ( {
10
8
render ( ) {
11
9
return (
12
10
< div style = { { textAlign : 'center' , padding : 50 } } >
13
- < img src = "spinner.gif" width = "64" height = "64" />
11
+ < img src = "spinner.gif" width = "64" height = "64" />
14
12
</ div >
15
13
) ;
16
14
}
@@ -52,7 +50,7 @@ var App = React.createClass({
52
50
return (
53
51
< div className = "App" style = { appStyle } >
54
52
< form onSubmit = { this . handleSubmit } >
55
- < input placeholder = "First name" /> < input placeholder = "Last name" /> { ' ' }
53
+ < input placeholder = "First name" /> < input placeholder = "Last name" /> { ' ' }
56
54
< button type = "submit" > submit</ button >
57
55
</ form >
58
56
< div style = { { display : 'flex' } } >
@@ -91,7 +89,7 @@ var Contact = React.createClass({
91
89
< div style = { { opacity : this . props . loadingAsyncProps ? 0.5 : 1 } } >
92
90
< p > < Link to = "/" > Back</ Link > </ p >
93
91
< 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 >
95
93
</ div >
96
94
) ;
97
95
}
@@ -107,12 +105,14 @@ var Index = React.createClass({
107
105
}
108
106
} ) ;
109
107
108
+ var history = createHistory ( ) ;
109
+
110
110
React . render ( (
111
111
< Router history = { history } createElement = { AsyncProps . createElement } >
112
- < Route component = { AsyncProps } renderInitialLoad = { ( ) => < Spinner /> } >
112
+ < Route component = { AsyncProps } renderInitialLoad = { ( ) => < Spinner /> } >
113
113
< 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 } />
116
116
</ Route >
117
117
</ Route >
118
118
</ Router >
0 commit comments