Walls is a react-router-dom
implementation that builds upon configuration.
If you use yarn, just run the following command in your project’s root directory.
yarn add walls
Or using npm:
npm install --save walls
import routes from './routes'
const MyApp = ({ isAuthorized, onUnauthorized }) => (
<Walls
routes={routes}
isAuthorized={isAuthorized}
onUnauthorized={onUnauthorized}
/>
)
You can write a roules config that looks like this (rotes.jsx
):
import React from 'react'
export default [{
private: false,
exact: true,
path: '/',
render: () => (
<p>Home</p>
),
}, {
private: false,
exact: true,
path: '/foo',
render: () => (
<p>Foo</p>
),
}, {
private: false,
exact: true,
path: '/bar',
render: () => (
<p>Bar</p>
),
}]
Walls is the main routing component
routes: Route[]
, configuration for all routesisAuthorized: boolean
, is current user authorizedonUnauthorized: function
, if not authorized, do this
private: boolean
, Is this route protected?exact: boolean
, Should the path match exactly?path: string
, path to this routerender: component
, a rendering functionfallback: component
, a rendering function as fallback for private routes
You can use these React Router functions via Walls:
Link
NavLink
Redirect
matchPath
withRouter
useHistory
useLocation
useParams
useRouteMatch
This framework is licensed under MIT