preact-nav-helper
Preact component for catching and handling internal links in your application.
Last updated 3 years ago by henrikjoreteg .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install preact-nav-helper 
SYNC missed versions from official npm registry.

preact-nav-helper

Preact component for catching and handling internal links in your application.

Wrap your root application in this component and you can use regular plain ol' <a> tags in your application code but still handle the ones that are "internal" to the application using your application logic.

Very importantly, it will not mess with browser capabilities, so it will not handle control clicks, right clicks, or tags with a target="_blank" attribute, etc.

install

npm install preact-nav-helper

example

const NavHelper = require("preact-nav-helper");

const YourRootComponent = () => {
  <NavHelper onInternalNav={doUpdateUrl}>
    <h1>Your app</h1>
    <a href="/">Some internal link</a>
    <a href="/other" target="_blank">Some internal link that should open in new window</a>
    <a href="http://joreteg.com">An external link, it will not try to handle this</a>
  </NavHeler>
};

credits

If you like this follow @HenrikJoreteg on twitter.

license

MIT

Current Tags

  • 1.0.0                                ...           latest (3 years ago)

1 Versions

  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |