Gathering detailed insights and metrics for react-director-router
Gathering detailed insights and metrics for react-director-router
Gathering detailed insights and metrics for react-director-router
Gathering detailed insights and metrics for react-director-router
npm install react-director-router
Typescript
Module System
Node Version
NPM Version
JavaScript (96.8%)
HTML (2.11%)
CSS (1.09%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
3 Stars
7 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Jul 11, 2019
Latest Version
1.0.4
Package Id
react-director-router@1.0.4
Unpacked Size
407.38 kB
Size
115.47 kB
File Count
11
NPM Version
5.6.0
Node Version
8.4.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
1
33
A versatile React Router based on Director
Makes your components cleaner by:
componentDidMount
for async data loading or state management.By using route handlers your view components can be more functional, more view related and carry less business logic.
Therefore view component tests would be simpler.
yarn start-example
yarn add react-director-router
1import Router from 'react-director-router' 2 3import HomeView from '../Views/HomeView' 4import BookWithStatus from '../Views/BookWithStatus' 5import NotFoundView from '../Views/NotFoundView' 6 7const routes = [ 8 { 9 path:'/', 10 viewClass: HomeView, 11 handler: () => { 12 console.log('Home handler'); 13 } 14 }, 15 { 16 path:'/book/:status/:id', 17 viewClass: BookWithStatus, 18 handler: (params) => { 19 console.log('/book/:status/:id > ', params) 20 }, 21 }, 22 { 23 path:'/not-found', 24 viewClass: NotFoundView 25 }, 26] 27 28const notFoundPath = '/not-found' 29 30const customProps = { 31 foo: 'bar', 32 count: 9000, 33 userRoles: ['basic-user'] 34} 35 36const HOCs = [ 37 view => someHigherOrderComponent(view), 38 view => anotherHigherOrderComponent(view), 39] 40 41const middlewares = [ 42 (injectedProps, params, queryParams, route) => { 43 console.log(':: Log Middleware ::', route.viewClass.name); 44 } 45] 46 47class App extends Component { 48 render() { 49 return ( 50 <div className="App"> 51 <Router 52 routes={routes} 53 notFoundPath={notFoundPath} 54 injectProps={customProps} 55 middlewares={middlewares} 56 viewHOCs={HOCs} 57 /> 58 </div> 59 ) 60 } 61} 62export default App
Middlewares are functions that can intercept every route change and are a great opportunity to restrict a route or redirect the navigation flow.
By returning false on any middleware function, the middleware execution sequence will be interrupted, the view will not render and the route handler will not run. You can then redirect the navigation flow acording to the desired business logic.
Another common use for a middleware is logging navigation activity.
A role restriction middleware:
1import { redirect } from 'react-director-router' 2 3export default function roleRestrictedMiddleware(injectedProps, params, queryParams, route) { 4 if (route.requiredRoles && injectedProps.userRoles){ 5 console.log(':: roleRestrictedMiddleware ::'); 6 const isAllowed = injectedProps.userRoles === route.requiredRoles 7 8 if (!isAllowed){ 9 redirect('restricted-content') 10 return isAllowed 11 } 12 } 13 }
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/7 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
145 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More