npm
npm install --save react-router-guard
yarn
yarn add react-router-guard
React Router Guard is a fully solution for react router system it include react-router-dom and support structure for you, the main feature includes (react router config as object, route-based code splitting and authentication router, router loading animation), use can using it by the easy way react-router-guard will be helps you save a lot of time to setup a react router system, for more information please read demo and docs
import React from 'react';
import ReactDOM from 'react-dom';
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);
name | type | default | description |
---|---|---|---|
Config | Array[Object] | The config for render all route | |
loading | Boolean|React.Element | true | The loading config for router |
history | createHashHistory() | null | Default router guard using createBrowserHistory you can change to hashHistory by pass history as props |
React Router Guard