File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,11 +31,17 @@ export default class LinkContainer extends React.Component {
3131 delete props . state ;
3232
3333 props . onClick = this . onClick ;
34- props . href = history . createHref ( to , query ) ;
35- if ( hash ) {
36- props . href += hash ;
34+
35+ // Ignore if rendered outside the context of history, simplifies unit testing.
36+ if ( history ) {
37+ props . href = history . createHref ( to , query ) ;
38+
39+ if ( hash ) {
40+ props . href += hash ;
41+ }
42+
43+ props . active = history . isActive ( to , query , onlyActiveOnIndex ) ;
3744 }
38- props . active = history . isActive ( to , query , onlyActiveOnIndex ) ;
3945
4046 return React . cloneElement ( React . Children . only ( children ) , props ) ;
4147 }
@@ -53,7 +59,7 @@ LinkContainer.propTypes = {
5359} ;
5460
5561LinkContainer . contextTypes = {
56- history : React . PropTypes . object . isRequired
62+ history : React . PropTypes . object
5763} ;
5864
5965LinkContainer . defaultProps = {
You can’t perform that action at this time.
0 commit comments