Gathering detailed insights and metrics for storybook-react-router-dom
Gathering detailed insights and metrics for storybook-react-router-dom
Gathering detailed insights and metrics for storybook-react-router-dom
Gathering detailed insights and metrics for storybook-react-router-dom
create-vite-react-template
Create a React App Template with ViteJS!
cra-template-stg
A quick start Create React App template with React Router, Redux Toolkit, TypeScript, React Testing Library and custom ESlint configurations. As well as, Storybook, Styled Components, Emotion, Material UI, Prettier, Husky and more.
cra-template-typescript-redditech
The base TypeScript template for Create React App with options for storybook, moment, react-router-dom and antd (Ant Design) modules added by Redditech. Early WIP.
react-boilerplate-template-api
A react template with 3-tier api architecture api > hook > ui , added configurations for vite-ts redux , toolkit , persist , react-router-dom , storybook
A storybook decorator that allows you to use routing-aware components in your stories
npm install storybook-react-router-dom
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
58 Commits
11 Branches
1 Contributors
Updated on Mar 11, 2021
Latest Version
6.1.21
Package Id
storybook-react-router-dom@6.1.21
Unpacked Size
7.61 kB
Size
2.90 kB
File Count
4
NPM Version
7.5.1
Node Version
15.8.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
1
4
A Storybook decorator that allows you to use your routing-aware components.
npm install --save-dev storybook-react-router-dom-dom
The decorator is actually a function which wraps the Router
instance. It accepts two optional arguments that you can use if you want to build a prototype of your navigation within storybook or if you need more control over the router itself.
In its default behavior the decorator just log every route action perfomed using the storybook action logger. If you are fine with the default arguments you can add globally the StoryRouter
decorator, however if you need to specify some of the arguments you have to use the decorator for every story that needs it.
Suppose you have a component that uses react-router Route
and Link
:
1import React from 'react'; 2import { Route, Link } from 'react-router-dom'; 3 4const ChildId = ({match}) => ( 5 <div> 6 <h3>ID: {match.params.id}</h3> 7 </div> 8); 9 10const ComponentParams = () => ( 11 <div> 12 <ul> 13 <li><Link to="/accounts/netflix">Netflix</Link></li> 14 <li><Link to="/accounts/sky">Sky</Link></li> 15 </ul> 16 <Route path="/accounts/:id" component={ChildId}/> 17 </div> 18); 19 20export default ComponentParams;
you can add the StoryRouter
decorator to your story this way:
1import { storiesOf } from '@storybook/react'; 2import StoryRouter from 'storybook-react-router-dom-dom'; 3 4import ComponentParams from '<your_component_path>/ComponentParams'; 5 6storiesOf('Params', module) 7 .addDecorator(StoryRouter()) 8 .add('params', () => ( 9 <ComponentParams/> 10 ));
If you want to use StoryRouter
in all your stories, you can also add it globally by editing your Storybook config.js
file:
1import { configure, addDecorator } from '@storybook/react'; 2import StoryRouter from 'storybook-react-router-dom'; 3 4addDecorator(StoryRouter()); 5 6// ...your config 7
The important thing is to call addDecorator
before calling configure
, otherwise it will not work!
The first argument is an object that you can use to extend the default behavior.
Every time that a key in the object matches with a path Storybook will call the callback specified for the corresponding value with the destination path as argument.
This way you can for example link stories together using the links
addons with the linkTo function.
The match is performed using the path-to-regexp module so you can also use parameter names and regexp within the link keys.
The second argument is another object which will be forwarded to the wrapped MemoryRouter
as props. This allows you to write stories having a specific url location or using advanced functionalities as asking the user confirmation before exiting from a location.
You can find more examples in the provided stories. You can run them cloning this repository and executing (supposing you have installed globally lerna):
yarn install && yarn bootstrap
yarn storybook-react-examples
As the wrapped Router creates a new history object for each story you cannot pass the history from a story to another one and so you cannot implement a back or forward button which works among stories.
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/30 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
162 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