@@ -54,46 +54,6 @@ var Link = React.createClass({
54
54
} ;
55
55
} ,
56
56
57
- getInitialState ( ) {
58
- var active = this . getActiveState ( ) ;
59
- return { active } ;
60
- } ,
61
-
62
- trySubscribe ( ) {
63
- var { history } = this . context ;
64
- if ( ! history ) return ;
65
- this . _unlisten = history . listen ( this . handleHistoryChange ) ;
66
- } ,
67
-
68
- tryUnsubscribe ( ) {
69
- if ( ! this . _unlisten ) return ;
70
- this . _unlisten ( ) ;
71
- this . _unlisten = undefined ;
72
- } ,
73
-
74
- handleHistoryChange ( ) {
75
- var { active } = this . state ;
76
- var nextActive = this . getActiveState ( ) ;
77
- if ( active !== nextActive ) {
78
- this . setState ( { active : nextActive } ) ;
79
- }
80
- } ,
81
-
82
- getActiveState ( ) {
83
- var { history } = this . context ;
84
- var { to, query, onlyActiveOnIndex } = this . props ;
85
- if ( ! history ) return false ;
86
- return history . isActive ( to , query , onlyActiveOnIndex ) ;
87
- } ,
88
-
89
- componentDidMount ( ) {
90
- this . trySubscribe ( ) ;
91
- } ,
92
-
93
- componentWillUnmount ( ) {
94
- this . tryUnsubscribe ( ) ;
95
- } ,
96
-
97
57
handleClick ( event ) {
98
58
var allowTransition = true ;
99
59
var clickResult ;
@@ -131,14 +91,13 @@ var Link = React.createClass({
131
91
} ;
132
92
133
93
var { history } = this . context ;
134
- var { active } = this . state ;
135
94
136
95
// Ignore if rendered outside the context
137
96
// of history, simplifies unit testing.
138
97
if ( history ) {
139
98
props . href = history . createHref ( to , query ) ;
140
99
141
- if ( active ) {
100
+ if ( history . isActive ( to , query , onlyActiveOnIndex ) ) {
142
101
if ( props . activeClassName )
143
102
props . className += props . className !== '' ? ` ${ props . activeClassName } ` : props . activeClassName ;
144
103
0 commit comments