1
1
var React = require ( 'react' ) ;
2
2
var Router = require ( 'react-router' ) ;
3
- var { Route, RouteHandler, Link, State } = Router ;
3
+ var { Route, RouteHandler, Link } = Router ;
4
4
5
5
var App = React . createClass ( {
6
6
getInitialState : function ( ) {
@@ -65,7 +65,10 @@ var Dashboard = React.createClass({
65
65
} ) ;
66
66
67
67
var Login = React . createClass ( {
68
- mixins : [ Router . Navigation , State ] ,
68
+
69
+ contextTypes : {
70
+ router : React . PropTypes . func . isRequired
71
+ } ,
69
72
70
73
getInitialState : function ( ) {
71
74
return {
@@ -75,17 +78,18 @@ var Login = React.createClass({
75
78
76
79
handleSubmit : function ( event ) {
77
80
event . preventDefault ( ) ;
78
- var nextPath = this . getQuery ( ) . nextPath ;
81
+ var { router } = this . context ;
82
+ var nextPath = router . getCurrentQuery ( ) . nextPath ;
79
83
var email = this . refs . email . getDOMNode ( ) . value ;
80
84
var pass = this . refs . pass . getDOMNode ( ) . value ;
81
85
auth . login ( email , pass , function ( loggedIn ) {
82
86
if ( ! loggedIn )
83
87
return this . setState ( { error : true } ) ;
84
88
85
89
if ( nextPath ) {
86
- this . replaceWith ( nextPath ) ;
90
+ router . replaceWith ( nextPath ) ;
87
91
} else {
88
- this . replaceWith ( '/about' ) ;
92
+ router . replaceWith ( '/about' ) ;
89
93
}
90
94
} . bind ( this ) ) ;
91
95
} ,
@@ -164,7 +168,7 @@ function pretendRequest(email, pass, cb) {
164
168
if ( email === '[email protected] ' && pass === 'password1' ) {
165
169
cb ( {
166
170
authenticated : true ,
167
- token : Math . random ( ) . toString ( 36 ) . substring ( 7 ) ,
171
+ token : Math . random ( ) . toString ( 36 ) . substring ( 7 )
168
172
} ) ;
169
173
} else {
170
174
cb ( { authenticated : false } ) ;
0 commit comments