@@ -43,12 +43,13 @@ class Link extends React.Component {
43
43
}
44
44
45
45
static propTypes = {
46
- activeStyle : object ,
47
- activeClassName : string ,
48
- onlyActiveOnIndex : bool . isRequired ,
49
46
to : string . isRequired ,
50
47
query : object ,
48
+ hash : string ,
51
49
state : object ,
50
+ activeStyle : object ,
51
+ activeClassName : string ,
52
+ onlyActiveOnIndex : bool . isRequired ,
52
53
onClick : func
53
54
}
54
55
@@ -77,16 +78,19 @@ class Link extends React.Component {
77
78
}
78
79
79
80
render ( ) {
80
- const { history } = this . context
81
- const { activeClassName, activeStyle, onlyActiveOnIndex, to, query, state, onClick, ...props } = this . props
81
+ const { to, query, hash, state, activeClassName, activeStyle, onlyActiveOnIndex, ...props } = this . props
82
82
83
+ // Manually override onClick.
83
84
props . onClick = ( e ) => this . handleClick ( e )
84
85
85
- // Ignore if rendered outside the context
86
- // of history, simplifies unit testing.
86
+ // Ignore if rendered outside the context of history, simplifies unit testing.
87
+ const { history } = this . context
87
88
if ( history ) {
88
89
props . href = history . createHref ( to , query )
89
90
91
+ if ( hash )
92
+ props . href += hash
93
+
90
94
if ( activeClassName || ( activeStyle != null && ! isEmptyObject ( activeStyle ) ) ) {
91
95
if ( history . isActive ( to , query , onlyActiveOnIndex ) ) {
92
96
if ( activeClassName )
0 commit comments