Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spencertorres/react-route-props
A react router route for passing props to the specified component.
https://github.com/spencertorres/react-route-props
javascript jsx props react react-component react-router react-router-v4 reactjs
Last synced: 4 days ago
JSON representation
A react router route for passing props to the specified component.
- Host: GitHub
- URL: https://github.com/spencertorres/react-route-props
- Owner: SpencerTorres
- License: mit
- Created: 2017-09-23T23:38:15.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-24T05:22:34.000Z (about 7 years ago)
- Last Synced: 2024-10-11T18:18:36.780Z (about 1 month ago)
- Topics: javascript, jsx, props, react, react-component, react-router, react-router-v4, reactjs
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/react-route-props
- Size: 38.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-route-props
This package is for easily passing extra props into react router's `Route` component. It adds a new component called `RouteProps` for achieving this.
## Install
**NPM**
```
npm install react-route-props
```
**Yarn**
```
yarn add react-route-props
```## Usage
```JSX
import { Component } from 'react'
import { Route, Switch, Redirect } from 'react-router-dom'import RouteProps from 'react-route-props'
import SomeStandaloneComponent from './SomeStandaloneComponent'
import SomeComponentWithProps from './SomeComponentWithProps'export default class App extends Component {
render() {
return (
)
}
}
````RouteProps` is just like `Route` with the difference of being able to pass extra props to the given `component`. Be careful with conflicting prop names for `Route`. You should add `Route` props to the left of the `component` prop as seen above with the `exact` prop.
There may be better ways to approach this, but this works for my projects using `react-router-v4`.
## License
react-route-props is released under the MIT license.