npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aleph/react-router-hijack-a

v1.2.0

Published

Watches HTML <a>-tag clicks and passes them to React Router if needed

Downloads

21

Readme

React Router Hijack

This React component allows React Router to handle raw HTML. It handles clicks on its children, checks if an <a> tag was clicked, and determines whether to process it as an internal react-router link or an external link.

Usage

import Hijack from '@aleph/react-router-hijack-a'

<Hijack>
  <div dangerouslySetInnerHTML={{ __html: `
    <a href='https://www.test.com'>internal link</a>
    <a href='https://www.google.com'>external link</a>
  ` }} />
</Hijack>

Props

The component accepts a protocols prop, which is a list of protocols that should be handled natively by the browser. By default, the component only expects 'mailto' and 'tel' protocols, so less common protocols such as 'ftp' will be handled incorrectly. Simply add any necessary protocols like so:

import Hijack from '@aleph/react-router-hijack-a'

<Hijack protocols={[ 'other' ]}>
  <div dangerouslySetInnerHTML={{ __html: `
    <a href='mailto:[email protected]'>email</a>
    <a href='other://example'>other protocol</a>
  ` }} />
</Hijack>

The component accepts a hostnames prop, which is a list of hostnames that should be interchangeable when referring to your app. If your site is available at a single hostname, there is no need to use this prop. Most often, it should be used to account for the www subdomain and bare domain being interchangeable:

import Hijack from '@aleph/react-router-hijack-a'

<Hijack hostnames={[ 'test.com', 'www.test.com' ]}>
  <div dangerouslySetInnerHTML={{ __html: `
    <a href='https://test.com/home'>homepage</a>
    <a href='https://www.test.com/home'>homepage</a>
  ` }} />
</Hijack>