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

react-router-pundit

v2.0.0

Published

React component that works with react-pundit and react-router-dom.

Downloads

2

Readme

react-router-pundit

build status Downloads Downloads npm version dependencies dev dependencies License

React component that works with react-pundit and react-router-dom.

With inspiration from React Pundit.

Pre-requisites

You need react-pundit and react-router-dom (React Router V4).

Getting Started

Install it via npm:

npm install --save react-pundit react-router-pundit react-router-dom

PunditRoute

PunditRoute will pass the original location to the Redirect via the location state as a from. this.props.location.state.from

PunditRoute can handle redirect paths as the return from the pundit check as well as the default boolean return.

Example

import { PunditContainer } from 'react-pundit';
import { PunditRoute, PassPropsRoute } from 'react-router-pundit';
import { Route } from 'react-router-dom';

import ReceiptView from '../ReceiptView';
import TacoView from '../TacoView';
import BasicView from '../BasicView';

import policies from './policies.js';
import './App.css';

class App extends Component {
  render() {
    const user = { id: 1, role: 'basic', activated: true };
    const receipt = { user: { id: 1 }, id: 45389, body: 'test', title: 'Receipt for 1/1/2017.' };

    return (
      <div className="App">
        <PunditContainer policies={policies} user={userOne}>
          <PunditRoute
            path={`/receipt/${receipt.id}`}
            exact
            component={ReceiptView}
            type="Receipt"
            action="View"
            model={receipt}
            user={user}
            redirectPath="/login"
            componentProps={{ receipt }}
          />
          <PassPropsRoute
            path="/tocos"
            exact
            componentProps={{ magic: true }}
            component={TacoView}
          />
          <Route path="/basic" component={BasicView} />
        </PunditContainer>
      </div>
    );
  }
}

API reference

// Available components
import {
  PunditRoute,
  PassPropsRoute
} from 'react-router-pundit';

Work in progress

Examples

See examples folder.

Testing changes locally

You can test changes by importing the library directly from a folder:

  1. Do changes to the library
  2. On your test project: npm install /path/to/your/react-router-pundit/ --save
  3. For easy development, you can npm link react-router-pundit on your application
  4. And finally npm run compile the react-router-pundit to have the changes in your application

License

MIT