Skip to content

Commit

Permalink
Fix issue with wrong NavLink's work
Browse files Browse the repository at this point in the history
  • Loading branch information
NumminorihSF committed Jan 23, 2019
1 parent 2bde50e commit d804e27
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/routing/Link.js
@@ -1,5 +1,6 @@
// @flow
import * as React from 'react';
import type { Match, Location } from 'react-router-dom';
import { NavLink as ReactRouterLink } from 'react-router-dom';

import { InjectedPath } from './InjectedPath';
Expand All @@ -13,6 +14,10 @@ type LinkState = { injectedRoute: ?InjectedPath, to: string };
* Link class.
*/
export class Link extends React.PureComponent<LinkProps, LinkState> {
static defaultProps = {
isActive: (path: *, match: Match, location: Location) => !!(match || path === location.pathname),
};

state = { to: '', injectedRoute: null };

/**
Expand Down
3 changes: 1 addition & 2 deletions src/routing/createLink.js
@@ -1,6 +1,5 @@
// @flow
import * as React from 'react';
import { withRouter } from 'react-router-dom';

import { Link } from './Link';
import { InjectedPath } from './InjectedPath';
Expand All @@ -26,5 +25,5 @@ export function createLink(to: string | InjectedPath) {
*/
const StaticLink = (props: LinkProps) => <Link {...props} to={to} />;

return withRouter(StaticLink);
return StaticLink;
}

0 comments on commit d804e27

Please sign in to comment.