New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-guarded-route

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-guarded-route

react-guarded-route allows you to guard your routes by a validation fuction.

latest
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

react-guarded-route

NPM JavaScript Style Guide

react-guarded-route allows you to guard your routes by a validation fuction.

Install

npm install --save react-guarded-route

Usage

import React, { Component } from 'react'

import GuardedRoute from 'react-guarded-route'
import { BrowserRouter, Route, Switch } from "react-router-dom";
import Dashboard from './Dashboard';
import Home from './Home';

const validatorFunction = () => {
  return true; //your validation logic
}

export default function App() {
  return(
    <Router>
        <Switch>
            <Route exact path = '/' component={Home}></Route>
            <GuardedRoute 
                path = '/dashboard'
                component = {Dashboard}
                redirectTo = '/login' //(Optional) Redirect to '/login' if validatorFunction returns false. Will redirect to '/' if not provided. 
                validatorFunction = {validatorFunction()}>
        </Switch>
    </Router>
  )
}

License

MIT ©

Keywords

react

FAQs

Package last updated on 24 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts