Skip to content

laptransang/react-router-guard

Repository files navigation

React Router Guard

NPM JavaScript Style Guide

Install

npm

npm install --save react-router-guard

yarn

yarn add react-router-guard

Introduction

React Router Guard is a router structure base on react-router-dom, when you install react-router-guard you don't need to install (react-router-dom, history, react-loadable) because it uses these packages as dependencies, it gives you some cool feature like router-config, code splitting, router authentication support, dynamic redirect for more information please read the demo and docs

Usage

import React from 'react';
import ReactDOM from 'react-dom';
/*
Because we don't need to install react-router-dom so you can use Link or NavLink from 'react-router-guard'
import { RouterGuard, BrowserRouter, Link, NavLink, Redirect, Route, Router, Switch, history, withRouter, Loadable } from 'react-router-guard';
*/
import { RouterGuard } from 'react-router-guard';
import config from './config';

function App() {
  return (
    <div className="App">
      <RouterGuard config={config} />
    </div>
  );
}

const rootElement = document.getElementById('root'); // eslint-disable-line
ReactDOM.render(<App />, rootElement);

API

name type description
config RouterGuardConfigProps[] The config for render all route
history createBrowserHistory() To use custom history

Docs

Migrating from 1.x to 2.x

Docs

Screenshot & Demo

Demo

React Router Guard

License

MIT © TSL

About

React Router Guard

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •