@@ -43,12 +43,13 @@ class Link extends React.Component {
4343 }
4444
4545 static propTypes = {
46- activeStyle : object ,
47- activeClassName : string ,
48- onlyActiveOnIndex : bool . isRequired ,
4946 to : string . isRequired ,
5047 query : object ,
48+ hash : string ,
5149 state : object ,
50+ activeStyle : object ,
51+ activeClassName : string ,
52+ onlyActiveOnIndex : bool . isRequired ,
5253 onClick : func
5354 }
5455
@@ -77,16 +78,19 @@ class Link extends React.Component {
7778 }
7879
7980 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
8282
83+ // Manually override onClick.
8384 props . onClick = ( e ) => this . handleClick ( e )
8485
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
8788 if ( history ) {
8889 props . href = history . createHref ( to , query )
8990
91+ if ( hash )
92+ props . href += hash
93+
9094 if ( activeClassName || ( activeStyle != null && ! isEmptyObject ( activeStyle ) ) ) {
9195 if ( history . isActive ( to , query , onlyActiveOnIndex ) ) {
9296 if ( activeClassName )
0 commit comments