react-router-config-recursive-prefixer
v0.1.0-beta.3
Published
Prefixes all of your react-router-config route tree paths with their parent paths... so that you don't have to!
Downloads
6
Maintainers
Readme
react-router-config-recursive-prefixer
A utility function which helps you recursively prefixes your routes with the parent path so that you don't need to type it by hand.
const rootRoutes = patchTreesRoutePath([ // Your typical route tree below...
{
path: '/app',
component: App,
routes: [
{
path: '/', // identical to '/app'!
exact: true,
component: RouteConfigComponent,
},
{
path: '/test', // identical to '/app/test'!
component: Test,
routes: [
{
path: '/this', // identical to '/app/test/this'!
component: TestThis,
},
{
path: '/that', // identical to '/app/test/that'!
component: That,
},
],
},
{
path: '*',
component: NotFound,
},
],
},
]);
Installation
You'll need React, React-Router (or its DOM or Native derivatives), React-Router-Config preinstalled in order to use this library.
NPM
# These are prerequisites
npm install --save react
npm install --save react-router # or react-router-dom... or react-router-native... they also import react-router, anyway
npm install --save react-router-config
# This library
npm install --save react-router-config-recursive-prefixer
Yarn
# These are prerequisites
yarn add react
yarn add react-router # or react-router-dom... or react-router-native... they also import react-router, anyway
yarn add react-router-config
# This library
yarn add react-router-config-recursive-prefixer
Contribution
This library is still very much a work in progress was hastily started so that it can be used immediately in bigger projects.
Ideas & support are more than welcome!
- Fork the project.
- Run the project in development mode:
yarn develop
. - Make changes to the code.
- Add new tests.
- Test the code:
yarn test
. If the tests fail, check the code again. Make sure the tests pass! - Lint the code:
yarn lint
. Clean up all linting errors. - Update this readme with regards to the new API changes.
- Commit the code.
- Create a pull request.
License
See: LICENSE.md
MIT.