@@ -54,46 +54,6 @@ var Link = React.createClass({
5454 } ;
5555 } ,
5656
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-
9757 handleClick ( event ) {
9858 var allowTransition = true ;
9959 var clickResult ;
@@ -131,14 +91,13 @@ var Link = React.createClass({
13191 } ;
13292
13393 var { history } = this . context ;
134- var { active } = this . state ;
13594
13695 // Ignore if rendered outside the context
13796 // of history, simplifies unit testing.
13897 if ( history ) {
13998 props . href = history . createHref ( to , query ) ;
14099
141- if ( active ) {
100+ if ( history . isActive ( to , query , onlyActiveOnIndex ) ) {
142101 if ( props . activeClassName )
143102 props . className += props . className !== '' ? ` ${ props . activeClassName } ` : props . activeClassName ;
144103
0 commit comments