1.0.6 • Published 8 years ago

do-link v1.0.6

Weekly downloads
-
License
MPL-2.0
Repository
gitlab
Last release
8 years ago

do-link

A Link-like component that will execute a specified function and/or navigate to a route when clicked.

The default react-router Link doesn't do both navigation and click listening (i.e., the navigation prevents the default action), so this gives you that choice back.

how it works

It's simple:

export function DoLink({ children, to, onClick, classes }) {

  function executeAndGo() {
    if (onClick instanceof Function) {
      onClick();
    }
    if (to) {
      browserHistory.push(to);
    }
  }

  return (
    <Link
       onClick={ executeAndGo }
       className={ classes }
    >
      { children }
    </Link>
  );
}
1.0.6

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago